Hallo,
I am using the PCAN_USB 1chan hardware to send a message.
Is there any chance I can know that the message was sent correctly ?
I always receive a PCAN_ERROR_OK .
thankyou
how to check message sent or not
Re: how to check message sent or not
Hi,
with the PCANBasic API you can only check for errors/status messages, which will occure when the message could not be transmitted by the CAN-Controller. With the optional available API of the PCAN-Developer package, you can use the selfreceive option to check the transmit of the CAN frame.
regards
Michael
with the PCANBasic API you can only check for errors/status messages, which will occure when the message could not be transmitted by the CAN-Controller. With the optional available API of the PCAN-Developer package, you can use the selfreceive option to check the transmit of the CAN frame.
regards
Michael
-
- Posts: 8
- Joined: Wed 2. Apr 2014, 14:39
Re: how to check message sent or not
Thanks Michael,
Recently, I have started working with python programming to communicate with PCAN-usb(Channel1) interfaced with ECU.
I am able to Initialize PCAN-USB, write message but i am unable to receive the data from ECU.
__________________________
but while using the PCAN view Explorer-5 I am able to write and read the data but not with python programming.
____________________________________________
can you please help out to fix this issue.
Thankingyou
if __name__ == '__main__':
msg = TPCANMsg()
tmstamp = TPCANTimestamp()
data = 0x22,0xF1,0x51
msg._fields_ = [ ("ID",0x602),("MSGTYPE", PCAN_MESSAGE_STANDARD),("LEN", 3),("DATA", data) ]
#______________________________________________________________________________________________
#----------------Initializ---------------------------
#_______________________________________________________________________________________________
can = PCANBasic()
print "hardwar:-", can.GetValue(PCAN_USBBUS1,PCAN_DEVICE_NUMBER)
result = can.Initialize(PCAN_USBBUS1, PCAN_BAUD_500K)
if result == PCAN_ERROR_OK:
print "Getstatus:-",can.GetStatus(PCAN_USBBUS1)
#______________________________________________________________________________________________
#--------------Writing/Sending _data------------------
#______________________________________________________________________________________________
wrtstat= can.Write(PCAN_USBBUS1,msg)
if (wrtstat == PCAN_ERROR_OK):
print "Message was sent"
else:
print "Error Occurred during writing"
#__________________________________________________________________________________________________
#-------------Reading----------------------------------
#_________________________________________________________________________________________________
can.Read(PCAN_USBBUS1)
status = PCAN_ERROR_QRCVEMPTY
print "beforeloop:-",status
while (status == PCAN_ERROR_OK ):
status,msg,time = can.Read(PCAN_USBBUS1)
can.FilterMessages(PCAN_USBBUS1, 0x400, 0x580, PCAN_MESSAGE_STANDARD)
print "inside loop:-", status
print "read:-",can.Read(PCAN_USBBUS1)
if (status == PCAN_ERROR_OK):
print "Message received"
#_________________________________________________________________________________________________
else:
print "Init error!"
print "End"
can.Uninitialize(PCAN_USBBUS1)
Recently, I have started working with python programming to communicate with PCAN-usb(Channel1) interfaced with ECU.
I am able to Initialize PCAN-USB, write message but i am unable to receive the data from ECU.
__________________________
but while using the PCAN view Explorer-5 I am able to write and read the data but not with python programming.
____________________________________________
can you please help out to fix this issue.
Thankingyou
if __name__ == '__main__':
msg = TPCANMsg()
tmstamp = TPCANTimestamp()
data = 0x22,0xF1,0x51
msg._fields_ = [ ("ID",0x602),("MSGTYPE", PCAN_MESSAGE_STANDARD),("LEN", 3),("DATA", data) ]
#______________________________________________________________________________________________
#----------------Initializ---------------------------
#_______________________________________________________________________________________________
can = PCANBasic()
print "hardwar:-", can.GetValue(PCAN_USBBUS1,PCAN_DEVICE_NUMBER)
result = can.Initialize(PCAN_USBBUS1, PCAN_BAUD_500K)
if result == PCAN_ERROR_OK:
print "Getstatus:-",can.GetStatus(PCAN_USBBUS1)
#______________________________________________________________________________________________
#--------------Writing/Sending _data------------------
#______________________________________________________________________________________________
wrtstat= can.Write(PCAN_USBBUS1,msg)
if (wrtstat == PCAN_ERROR_OK):
print "Message was sent"
else:
print "Error Occurred during writing"
#__________________________________________________________________________________________________
#-------------Reading----------------------------------
#_________________________________________________________________________________________________
can.Read(PCAN_USBBUS1)
status = PCAN_ERROR_QRCVEMPTY
print "beforeloop:-",status
while (status == PCAN_ERROR_OK ):
status,msg,time = can.Read(PCAN_USBBUS1)
can.FilterMessages(PCAN_USBBUS1, 0x400, 0x580, PCAN_MESSAGE_STANDARD)
print "inside loop:-", status
print "read:-",can.Read(PCAN_USBBUS1)
if (status == PCAN_ERROR_OK):
print "Message received"
#_________________________________________________________________________________________________
else:
print "Init error!"
print "End"
can.Uninitialize(PCAN_USBBUS1)
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: how to check message sent or not
your code looks trange in the reading section...please studi the phyton sample code, which is part of the PCAN-Basic API package. This work fine and show also how to receive CAN Frames.
You also have to read the Help File before you start coding . The way you set filter or read the satus could not work this way - filters need to be set BEFORE you call CAN-Read
You also have to read the Help File before you start coding . The way you set filter or read the satus could not work this way - filters need to be set BEFORE you call CAN-Read
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
-
- Posts: 8
- Joined: Wed 2. Apr 2014, 14:39
Re: how to check message sent or not
Hi U.Wilhelm thanks for your reply,
#__________________________________________________________________________________________________
#-------------Reading----------------------------------
#_________________________________________________________________________________________________
can.FilterMessages(PCAN_USBBUS1, 0x400, 0x580, PCAN_MESSAGE_STANDARD)
status = PCAN_ERROR_QRCVEMPTY
print "beforeloop:-",status
while((status & PCAN_ERROR_QRCVEMPTY) == PCAN_ERROR_QRCVEMPTY):
status,msg,Time = can.Read(PCAN_USBBUS1)
print status
if (status == PCAN_ERROR_OK):
print "Message sucessfully received "
else:
error = can.GetErrorText(PCAN_ERROR_QRCVEMPTY , 0)
print "inside loop:-", status
time.sleep(1)
_______________________________________________________________________________________________
output:-
beforeloop:- 32
32
inside loop:- 32
4
inside loop:- 4
End
______________________________________________________________________________________
even after following your instructions i am unable to read the data. but this time I am getting error status as
PCAN_ERROR_BUSLIGHT(4).
#__________________________________________________________________________________________________
#-------------Reading----------------------------------
#_________________________________________________________________________________________________
can.FilterMessages(PCAN_USBBUS1, 0x400, 0x580, PCAN_MESSAGE_STANDARD)
status = PCAN_ERROR_QRCVEMPTY
print "beforeloop:-",status
while((status & PCAN_ERROR_QRCVEMPTY) == PCAN_ERROR_QRCVEMPTY):
status,msg,Time = can.Read(PCAN_USBBUS1)
print status
if (status == PCAN_ERROR_OK):
print "Message sucessfully received "
else:
error = can.GetErrorText(PCAN_ERROR_QRCVEMPTY , 0)
print "inside loop:-", status
time.sleep(1)
_______________________________________________________________________________________________
output:-
beforeloop:- 32
32
inside loop:- 32
4
inside loop:- 4
End
______________________________________________________________________________________
even after following your instructions i am unable to read the data. but this time I am getting error status as
PCAN_ERROR_BUSLIGHT(4).
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: how to check message sent or not
1. why do you post the same question in 2 threads - please google the world wide forum rules
2. you did not read the manual and did not read the sample you only move one line of code (filter) to a other position.
read and study the example - try to understand how it works!
Thats why we invest a lot of time in documentaion and sample code.
We will do support after you have invest some time to understand the basics - all your problems are well documented in the code and in the Help Files. We could not do support in python basics - please contact some people in python forums
2. you did not read the manual and did not read the sample you only move one line of code (filter) to a other position.
read and study the example - try to understand how it works!
Thats why we invest a lot of time in documentaion and sample code.
We will do support after you have invest some time to understand the basics - all your problems are well documented in the code and in the Help Files. We could not do support in python basics - please contact some people in python forums
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------