8
8
#
9
9
# ------------------------------------------------------------------
10
10
# Author : Keneth Wagner
11
- # Last change: 14.01.2021 Wagner
12
- #
13
- # Language: Python 2.7, 3.7
14
11
# ------------------------------------------------------------------
15
12
#
16
13
# Copyright (C) 1999-2021 PEAK-System Technik GmbH, Darmstadt
17
14
# more Info at http://www.peak-system.com
18
- #
19
15
20
16
# Module Imports
21
- #
22
17
from ctypes import *
23
18
from ctypes .util import find_library
24
19
from string import *
@@ -553,6 +548,102 @@ class TPCANChannelInformation(Structure):
553
548
] # Availability status of a PCAN-Channel
554
549
555
550
551
+ # ///////////////////////////////////////////////////////////
552
+ # Additional objects
553
+ # ///////////////////////////////////////////////////////////
554
+
555
+ PCAN_BITRATES = {
556
+ 1000000 : PCAN_BAUD_1M ,
557
+ 800000 : PCAN_BAUD_800K ,
558
+ 500000 : PCAN_BAUD_500K ,
559
+ 250000 : PCAN_BAUD_250K ,
560
+ 125000 : PCAN_BAUD_125K ,
561
+ 100000 : PCAN_BAUD_100K ,
562
+ 95000 : PCAN_BAUD_95K ,
563
+ 83000 : PCAN_BAUD_83K ,
564
+ 50000 : PCAN_BAUD_50K ,
565
+ 47000 : PCAN_BAUD_47K ,
566
+ 33000 : PCAN_BAUD_33K ,
567
+ 20000 : PCAN_BAUD_20K ,
568
+ 10000 : PCAN_BAUD_10K ,
569
+ 5000 : PCAN_BAUD_5K ,
570
+ }
571
+
572
+ PCAN_FD_PARAMETER_LIST = (
573
+ "nom_brp" ,
574
+ "nom_tseg1" ,
575
+ "nom_tseg2" ,
576
+ "nom_sjw" ,
577
+ "data_brp" ,
578
+ "data_tseg1" ,
579
+ "data_tseg2" ,
580
+ "data_sjw" ,
581
+ )
582
+
583
+ PCAN_CHANNEL_NAMES = {
584
+ "PCAN_NONEBUS" : PCAN_NONEBUS ,
585
+ "PCAN_ISABUS1" : PCAN_ISABUS1 ,
586
+ "PCAN_ISABUS2" : PCAN_ISABUS2 ,
587
+ "PCAN_ISABUS3" : PCAN_ISABUS3 ,
588
+ "PCAN_ISABUS4" : PCAN_ISABUS4 ,
589
+ "PCAN_ISABUS5" : PCAN_ISABUS5 ,
590
+ "PCAN_ISABUS6" : PCAN_ISABUS6 ,
591
+ "PCAN_ISABUS7" : PCAN_ISABUS7 ,
592
+ "PCAN_ISABUS8" : PCAN_ISABUS8 ,
593
+ "PCAN_DNGBUS1" : PCAN_DNGBUS1 ,
594
+ "PCAN_PCIBUS1" : PCAN_PCIBUS1 ,
595
+ "PCAN_PCIBUS2" : PCAN_PCIBUS2 ,
596
+ "PCAN_PCIBUS3" : PCAN_PCIBUS3 ,
597
+ "PCAN_PCIBUS4" : PCAN_PCIBUS4 ,
598
+ "PCAN_PCIBUS5" : PCAN_PCIBUS5 ,
599
+ "PCAN_PCIBUS6" : PCAN_PCIBUS6 ,
600
+ "PCAN_PCIBUS7" : PCAN_PCIBUS7 ,
601
+ "PCAN_PCIBUS8" : PCAN_PCIBUS8 ,
602
+ "PCAN_PCIBUS9" : PCAN_PCIBUS9 ,
603
+ "PCAN_PCIBUS10" : PCAN_PCIBUS10 ,
604
+ "PCAN_PCIBUS11" : PCAN_PCIBUS11 ,
605
+ "PCAN_PCIBUS12" : PCAN_PCIBUS12 ,
606
+ "PCAN_PCIBUS13" : PCAN_PCIBUS13 ,
607
+ "PCAN_PCIBUS14" : PCAN_PCIBUS14 ,
608
+ "PCAN_PCIBUS15" : PCAN_PCIBUS15 ,
609
+ "PCAN_PCIBUS16" : PCAN_PCIBUS16 ,
610
+ "PCAN_USBBUS1" : PCAN_USBBUS1 ,
611
+ "PCAN_USBBUS2" : PCAN_USBBUS2 ,
612
+ "PCAN_USBBUS3" : PCAN_USBBUS3 ,
613
+ "PCAN_USBBUS4" : PCAN_USBBUS4 ,
614
+ "PCAN_USBBUS5" : PCAN_USBBUS5 ,
615
+ "PCAN_USBBUS6" : PCAN_USBBUS6 ,
616
+ "PCAN_USBBUS7" : PCAN_USBBUS7 ,
617
+ "PCAN_USBBUS8" : PCAN_USBBUS8 ,
618
+ "PCAN_USBBUS9" : PCAN_USBBUS9 ,
619
+ "PCAN_USBBUS10" : PCAN_USBBUS10 ,
620
+ "PCAN_USBBUS11" : PCAN_USBBUS11 ,
621
+ "PCAN_USBBUS12" : PCAN_USBBUS12 ,
622
+ "PCAN_USBBUS13" : PCAN_USBBUS13 ,
623
+ "PCAN_USBBUS14" : PCAN_USBBUS14 ,
624
+ "PCAN_USBBUS15" : PCAN_USBBUS15 ,
625
+ "PCAN_USBBUS16" : PCAN_USBBUS16 ,
626
+ "PCAN_PCCBUS1" : PCAN_PCCBUS1 ,
627
+ "PCAN_PCCBUS2" : PCAN_PCCBUS2 ,
628
+ "PCAN_LANBUS1" : PCAN_LANBUS1 ,
629
+ "PCAN_LANBUS2" : PCAN_LANBUS2 ,
630
+ "PCAN_LANBUS3" : PCAN_LANBUS3 ,
631
+ "PCAN_LANBUS4" : PCAN_LANBUS4 ,
632
+ "PCAN_LANBUS5" : PCAN_LANBUS5 ,
633
+ "PCAN_LANBUS6" : PCAN_LANBUS6 ,
634
+ "PCAN_LANBUS7" : PCAN_LANBUS7 ,
635
+ "PCAN_LANBUS8" : PCAN_LANBUS8 ,
636
+ "PCAN_LANBUS9" : PCAN_LANBUS9 ,
637
+ "PCAN_LANBUS10" : PCAN_LANBUS10 ,
638
+ "PCAN_LANBUS11" : PCAN_LANBUS11 ,
639
+ "PCAN_LANBUS12" : PCAN_LANBUS12 ,
640
+ "PCAN_LANBUS13" : PCAN_LANBUS13 ,
641
+ "PCAN_LANBUS14" : PCAN_LANBUS14 ,
642
+ "PCAN_LANBUS15" : PCAN_LANBUS15 ,
643
+ "PCAN_LANBUS16" : PCAN_LANBUS16 ,
644
+ }
645
+
646
+
556
647
# ///////////////////////////////////////////////////////////
557
648
# PCAN-Basic API function declarations
558
649
# ///////////////////////////////////////////////////////////
@@ -601,8 +692,7 @@ def Initialize(
601
692
Interrupt = c_ushort (0 ),
602
693
):
603
694
604
- """
605
- Initializes a PCAN Channel
695
+ """Initializes a PCAN Channel
606
696
607
697
Parameters:
608
698
Channel : A TPCANHandle representing a PCAN Channel
@@ -627,8 +717,7 @@ def Initialize(
627
717
#
628
718
def InitializeFD (self , Channel , BitrateFD ):
629
719
630
- """
631
- Initializes a FD capable PCAN Channel
720
+ """Initializes a FD capable PCAN Channel
632
721
633
722
Parameters:
634
723
Channel : The handle of a FD capable PCAN Channel
@@ -659,8 +748,7 @@ def InitializeFD(self, Channel, BitrateFD):
659
748
#
660
749
def Uninitialize (self , Channel ):
661
750
662
- """
663
- Uninitializes one or all PCAN Channels initialized by CAN_Initialize
751
+ """Uninitializes one or all PCAN Channels initialized by CAN_Initialize
664
752
665
753
Remarks:
666
754
Giving the TPCANHandle value "PCAN_NONEBUS", uninitialize all initialized channels
@@ -682,8 +770,7 @@ def Uninitialize(self, Channel):
682
770
#
683
771
def Reset (self , Channel ):
684
772
685
- """
686
- Resets the receive and transmit queues of the PCAN Channel
773
+ """Resets the receive and transmit queues of the PCAN Channel
687
774
688
775
Remarks:
689
776
A reset of the CAN controller is not performed
@@ -705,8 +792,7 @@ def Reset(self, Channel):
705
792
#
706
793
def GetStatus (self , Channel ):
707
794
708
- """
709
- Gets the current status of a PCAN Channel
795
+ """Gets the current status of a PCAN Channel
710
796
711
797
Parameters:
712
798
Channel : A TPCANHandle representing a PCAN Channel
@@ -725,8 +811,7 @@ def GetStatus(self, Channel):
725
811
#
726
812
def Read (self , Channel ):
727
813
728
- """
729
- Reads a CAN message from the receive queue of a PCAN Channel
814
+ """Reads a CAN message from the receive queue of a PCAN Channel
730
815
731
816
Remarks:
732
817
The return value of this method is a 3-touple, where
@@ -740,7 +825,7 @@ def Read(self, Channel):
740
825
Channel : A TPCANHandle representing a PCAN Channel
741
826
742
827
Returns:
743
- A touple with three values
828
+ A tuple with three values
744
829
"""
745
830
try :
746
831
msg = TPCANMsg ()
@@ -755,8 +840,7 @@ def Read(self, Channel):
755
840
#
756
841
def ReadFD (self , Channel ):
757
842
758
- """
759
- Reads a CAN message from the receive queue of a FD capable PCAN Channel
843
+ """Reads a CAN message from the receive queue of a FD capable PCAN Channel
760
844
761
845
Remarks:
762
846
The return value of this method is a 3-touple, where
@@ -770,7 +854,7 @@ def ReadFD(self, Channel):
770
854
Channel : The handle of a FD capable PCAN Channel
771
855
772
856
Returns:
773
- A touple with three values
857
+ A tuple with three values
774
858
"""
775
859
try :
776
860
msg = TPCANMsgFD ()
@@ -785,8 +869,7 @@ def ReadFD(self, Channel):
785
869
#
786
870
def Write (self , Channel , MessageBuffer ):
787
871
788
- """
789
- Transmits a CAN message
872
+ """Transmits a CAN message
790
873
791
874
Parameters:
792
875
Channel : A TPCANHandle representing a PCAN Channel
@@ -806,8 +889,7 @@ def Write(self, Channel, MessageBuffer):
806
889
#
807
890
def WriteFD (self , Channel , MessageBuffer ):
808
891
809
- """
810
- Transmits a CAN message over a FD capable PCAN Channel
892
+ """Transmits a CAN message over a FD capable PCAN Channel
811
893
812
894
Parameters:
813
895
Channel : The handle of a FD capable PCAN Channel
@@ -827,8 +909,7 @@ def WriteFD(self, Channel, MessageBuffer):
827
909
#
828
910
def FilterMessages (self , Channel , FromID , ToID , Mode ):
829
911
830
- """
831
- Configures the reception filter
912
+ """Configures the reception filter
832
913
833
914
Remarks:
834
915
The message filter will be expanded with every call to this function.
@@ -855,8 +936,7 @@ def FilterMessages(self, Channel, FromID, ToID, Mode):
855
936
#
856
937
def GetValue (self , Channel , Parameter ):
857
938
858
- """
859
- Retrieves a PCAN Channel value
939
+ """Retrieves a PCAN Channel value
860
940
861
941
Remarks:
862
942
Parameters can be present or not according with the kind
@@ -872,7 +952,7 @@ def GetValue(self, Channel, Parameter):
872
952
Parameter : The TPCANParameter parameter to get
873
953
874
954
Returns:
875
- A touple with 2 values
955
+ A tuple with 2 values
876
956
"""
877
957
try :
878
958
if (
@@ -912,9 +992,8 @@ def GetValue(self, Channel, Parameter):
912
992
#
913
993
def SetValue (self , Channel , Parameter , Buffer ):
914
994
915
- """
916
- Returns a descriptive text of a given TPCANStatus error
917
- code, in any desired language
995
+ """Returns a descriptive text of a given TPCANStatus error
996
+ code, in any desired language
918
997
919
998
Remarks:
920
999
Parameters can be present or not according with the kind
@@ -951,8 +1030,7 @@ def SetValue(self, Channel, Parameter, Buffer):
951
1030
952
1031
def GetErrorText (self , Error , Language = 0 ):
953
1032
954
- """
955
- Configures or sets a PCAN Channel value
1033
+ """Configures or sets a PCAN Channel value
956
1034
957
1035
Remarks:
958
1036
@@ -969,7 +1047,7 @@ def GetErrorText(self, Error, Language=0):
969
1047
Language : Indicates a 'Primary language ID' (Default is Neutral(0))
970
1048
971
1049
Returns:
972
- A touple with 2 values
1050
+ A tuple with 2 values
973
1051
"""
974
1052
try :
975
1053
mybuffer = create_string_buffer (256 )
@@ -981,8 +1059,7 @@ def GetErrorText(self, Error, Language=0):
981
1059
982
1060
def LookUpChannel (self , Parameters ):
983
1061
984
- """
985
- Finds a PCAN-Basic channel that matches with the given parameters
1062
+ """Finds a PCAN-Basic channel that matches with the given parameters
986
1063
987
1064
Remarks:
988
1065
@@ -995,7 +1072,7 @@ def LookUpChannel(self, Parameters):
995
1072
to be matched within a PCAN-Basic channel
996
1073
997
1074
Returns:
998
- A touple with 2 values
1075
+ A tuple with 2 values
999
1076
"""
1000
1077
try :
1001
1078
mybuffer = TPCANHandle (0 )
0 commit comments