I am using the PCAN-USB Pro and I have successfully sent USB to CAN frames with Python (Initialized-Write-Uninitialize) as you could see on the following capture on the PCAN-View, and I have connected the PCAN USB Pro with an Anybus Communicator gateway with a female CAN-CAN Cable and I see that the frames sent from python are not sent to the Anybus Communicator I have checked the CAN-CAN cable pins that there is a resistance of 120ohm termination and the Pins are well compatible with the Pin of the PCAN and Gatway.
I want to know if the frames I sent from Python code to the PCAN will be sent automatically from the PCAN to another tool ?
it will be necessary to make another program to send to the Anybus Communicator or not? otherwise where i could have a problem ?
Thanks for your help
- PCAN-View.PNG (49.37 KiB) Viewed 2815 times
Please make sure that you use the right baudrate to communicate with this hardware you trying to communicate with.
Secondly, if you want to view the messages from your PCANBasic-Application in PCAN-View, make sure that you use the exact same channel as your PCAN-View application.
Start your PCANBasic-application
Initialize the same channel as your PCANBasic application with PCAN-View.
You'll receive a warning that "This hardware is already in use by another software! the bitrate cannot be changed".
See if this will result in the messages being sent by your PCANBasic application to appear in the receive window of PCAN-View:
The Transmit-Window show messages which were created and sent by PCAN-View itself
Thank you for your explanation that I checked and I am on the same speed, but I want to know if the frames sent from USB to CAN (from my computer i.e. python code to PCAN-USB Pro) will be automatically transmitted from the CAN to another device (PCAN USB Pro to the gateway) connected to the CAN bus of the PCAN-USB Pro?
Because on the PCAN view I see that the received frames and that does not tell me that they are transmitted.
knowing that I used the 3 steps (Initialize- Write-Initialize)
I need to add other function to allow to send from my PCAN USB Pro to another hardware
Code: Select all
from PCANBasic import * #Initialize the PCAN m_PCAN = PCANBasic() m_Result = m_PCAN.Initialize(PCAN_USBBUS1, PCAN_BAUD_500K) # creation of the frame m_Msg = TPCANMsg() m_Msg m_Msg.ID = 0x103 m_Msg.LEN =3 m_Msg.DATA = 0xA m_Msg.DATA = 0xB m_Msg.DATA = 0xC m_Msg.DATA = 0xD m_Msg.MSGTYPE = PCAN_MESSAGE_STANDARD m_Result = m_PCAN.Write(PCAN_USBBUS1,m_Msg) if m_Result == PCAN_ERROR_OK : print("Message sent") # Uninitialize the PCAN m_PCAN.Uninitialize(PCAN_USBBUS1)
when I execute this code I see on the PCAN View that it has received but I want to know what I must add so that the frame will be transmitted from the PCAN to the gateway
You dont need to add anything to send the message on the bus, the "write" method like used
in your example is sufficent for that.
Your code itself works, like you can see here:
Also another CAN-Node was able to receive this message on the bus:
PCAN-View, like previously mentioned, will not display messages in the transmit-window, if the message was not directly created and sent by PCAN-View itself. A message sent on the same PCAN-Net (Aka. Same Hardware) will be displayed in the receive-window.
If you cannot seem to establish a communication between your python application and your Gateway-device, this is most likely due to a physical issue (wrong baudrate, over/undertermination)
Can you describe to us, what you are expecting and what exactly does not work?
i want to know if what i can do is doable, if yes i want to know what i should do or added to my code
I know that I can do it from the PCAN View to the gateway but I am trying to send it from my python code
Please send us a complete Screenshot of your PCAN-View communicating with this gateway device, like you already did.
Please make sure to include the status bar at the bottom of pcanview: