Python - CANTP_Read returns CANTP_Write DATA
Posted: Wed 8. Jun 2016, 16:38
Hello,
i'm trying to use the PCAN-ISO-TP.dll to communicate to an ECU via PCAN-USB.
As i'm asked to build my program in Python (2.7) on Win7 64Bit. So i created a wrapper for the PCAN-ISO-TP.dll using ctypes and started to integrate a first few simple diagnostic tests for my ECU.
When i'm using the CANTP_Write function to send my data structure, i see the message on the CAN-Bus.
When i'm using the CANTP_Read function, i get a data structure (MSGTYPE: PCANTP_MESSAGE_REQUEST_CONFIRMATION, RESULT: PCANTP_N_OK) even if my ECU is not connected to the PCAN device. The RX DATA field is always filled with my TX-Data. Even if the ECU is attached to the PCAN device, the effect stays the same.
I suspect an problem with the ctypes structure or/and the used DATA c_ubyte Array Buffer but were not able to find an equal problems and helpful solutions in certain forums.
I hope someone here is able to give me a good hint.
CANTP_AddMapping()
CANTP_Read()
CANTP_Write()
TX Message Structure
RX Message Structure
i'm trying to use the PCAN-ISO-TP.dll to communicate to an ECU via PCAN-USB.
As i'm asked to build my program in Python (2.7) on Win7 64Bit. So i created a wrapper for the PCAN-ISO-TP.dll using ctypes and started to integrate a first few simple diagnostic tests for my ECU.
When i'm using the CANTP_Write function to send my data structure, i see the message on the CAN-Bus.
When i'm using the CANTP_Read function, i get a data structure (MSGTYPE: PCANTP_MESSAGE_REQUEST_CONFIRMATION, RESULT: PCANTP_N_OK) even if my ECU is not connected to the PCAN device. The RX DATA field is always filled with my TX-Data. Even if the ECU is attached to the PCAN device, the effect stays the same.
I suspect an problem with the ctypes structure or/and the used DATA c_ubyte Array Buffer but were not able to find an equal problems and helpful solutions in certain forums.
I hope someone here is able to give me a good hint.
CANTP_AddMapping()
Code: Select all
Channel=channel
canID=tx_id,
canIDResponse=rx_id,
canIdType=PCANTP_ID_CAN_11BIT,
formatType=PCANTP_FORMAT_NORMAL,
msgType=PCANTP_MESSAGE_DIAGNOSTIC,
sourceAddr=0,
targetAddr=0,
targetType=PCANTP_ADDRESSING_PHYSICAL,
remoteAddr=0
Code: Select all
msgObj = TPCANTPMsg()
tmObj = TPCANTPTimestamp()
res = self.__m_dllBasic.CANTP_Read(Channel, byref(msgObj), byref(tmObj))
Code: Select all
res = self.__m_dllBasic.CANTP_Write(Channel, byref(MessageBuffer))
Code: Select all
DATA : <PCAN_ISOTP_Wrapper.c_ubyte_Array_4095 object at 0x02652BC0>
DATA[..] : 10 03
FORMAT : 1
FORMAT : PCANTP_FORMAT_NORMAL
IDTYPE : 1
IDTYPE : PCANTP_ID_CAN_11BIT
LEN : 2
MSGTYPE : 1
MSGTYPE : PCANTP_MESSAGE_DIAGNOSTIC
RA : 0
RESULT : 0
RESULT : PCANTP_N_OK
SA : 0
TA : 0
TA_TYPE : 1
TA_TYPE : PCANTP_ADDRESSING_PHYSICAL
Code: Select all
DATA : <PCAN_ISOTP_Wrapper.c_ubyte_Array_4095 object at 0x02652C60>
DATA[..] : 10 03
FORMAT : 1
FORMAT : PCANTP_FORMAT_NORMAL
IDTYPE : 1
IDTYPE : PCANTP_ID_CAN_11BIT
LEN : 2
MSGTYPE : 3
MSGTYPE : PCANTP_MESSAGE_REQUEST_CONFIRMATION
RA : 0
RESULT : 0
RESULT : PCANTP_N_OK
SA : 0
TA : 0
TA_TYPE : 1
TA_TYPE : PCANTP_ADDRESSING_PHYSICAL