problème communication

High-speed USB 2.0 to CAN/LIN Interface
MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

problème communication

Post by MOUHOUBI » Fri 17. Jul 2020, 10:47

Hello,

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
Attachments
PCAN-View.PNG
PCAN-View.PNG (49.37 KiB) Viewed 3188 times

M.Heidemann
Sales & Support
Sales & Support
Posts: 786
Joined: Fri 20. Sep 2019, 13:31

Re: problème communication

Post by M.Heidemann » Fri 17. Jul 2020, 13:05

Hello,

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.

Step 1:

Start your PCANBasic-application

Step 2:

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".

Step 3:

See if this will result in the messages being sent by your PCANBasic application to appear in the receive window of PCAN-View:
PCANBasic Traffic.PNG
PCANBasic Traffic.PNG (49.68 KiB) Viewed 3171 times
The Transmit-Window show messages which were created and sent by PCAN-View itself


Best Regards


Marvin

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: problème communication

Post by MOUHOUBI » Fri 17. Jul 2020, 14:26

Hello,

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

cordially

M.Heidemann
Sales & Support
Sales & Support
Posts: 786
Joined: Fri 20. Sep 2019, 13:31

Re: problème communication

Post by M.Heidemann » Fri 17. Jul 2020, 14:38

Hello,

Please share your code with us,
and explain to us, what you are refering to.



Best Regards

Marvin

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: problème communication

Post by MOUHOUBI » Fri 17. Jul 2020, 14:58

here is the code i use to send the frame:

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[0] = 0xA
m_Msg.DATA[1] = 0xB
m_Msg.DATA[2] = 0xC
m_Msg.DATA[3] = 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

thanks again

cordially

M.Heidemann
Sales & Support
Sales & Support
Posts: 786
Joined: Fri 20. Sep 2019, 13:31

Re: problème communication

Post by M.Heidemann » Fri 17. Jul 2020, 15:31

Hello,

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:
PythonTestRun.PNG
PythonTestRun.PNG (48.35 KiB) Viewed 3137 times


Also another CAN-Node was able to receive this message on the bus:
CAN_Reception other node.PNG
CAN_Reception other node.PNG (21.93 KiB) Viewed 3137 times
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?

Best Regards

Marvin

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: problème communication

Post by MOUHOUBI » Fri 17. Jul 2020, 16:16

Here is the diagram of what I want to do and what works and what does not.
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
discription.PNG
discription.PNG (138.26 KiB) Viewed 3131 times

Thank you

Cordly

M.Heidemann
Sales & Support
Sales & Support
Posts: 786
Joined: Fri 20. Sep 2019, 13:31

Re: problème communication

Post by M.Heidemann » Fri 17. Jul 2020, 16:27

Hello,

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:
StatusBar.PNG
StatusBar.PNG (2.39 KiB) Viewed 3125 times

Best Regards

Marvin

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: problème communication

Post by MOUHOUBI » Fri 17. Jul 2020, 16:56

I do not know if the statue which causes the problem but I arrive sent frames from another adapter USB CAN with its monitor and I receive well but for on the PCAN USB PRO and I also send from my PCAN PRO and I sees that the sent frames are well received.
screen.PNG
screen.PNG (99.07 KiB) Viewed 3122 times
screen2PNG.PNG
screen2PNG.PNG (309 KiB) Viewed 3122 times

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: problème communication

Post by MOUHOUBI » Sat 18. Jul 2020, 20:56

Hello,

Thank you very much for your help I just solved the problem, it was the BUSHEAVY Statue in the end and sorry for the inconvenience.

cordially

Locked