PCANBasic: problem using LISTEN_ONLY mode

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
A.Kapp
Posts: 10
Joined: Wed 29. Feb 2012, 09:43

PCANBasic: problem using LISTEN_ONLY mode

Post by A.Kapp » Fri 9. Mar 2012, 07:49

Hello,

I am using a PCAN-USB adapter (channel version 3.8.2.10146) with PCANBasic.dll (version from 2012.01.20) under Python 2.6 on a Windows 7 machine.
When following the procedure given in the PCAN-Basic documentation about the parameter PCAN_LISTEN_ONLY, I manage to set its value to PCAN_PARAMETER_ON.
However, a following CAN_Send command still sends a message (cf. code snippet).
I check the message queue with PCAN-View (version 3.1.5.200) which is started after the channel has already been initialized.

Probably, I am getting the term LISTEN_ONLY mode wrong.
My intention is to force a channel to listen only.

Regards,

Andreas

Code: Select all

a = PCANBasic.PCANBasic()
msg = PCANBasic.TPCANMsg()
msg.MSGTYPE = PCANBasic.PCAN_MESSAGE_EXTENDED

chA = PCANBasic.PCAN_USBBUS1
baudrate = PCANBasic.PCAN_BAUD_500K

# pre-initialization for LISTEN_ONLY mode
a.SetValue(chA, PCANBasic.PCAN_LISTEN_ONLY, PCANBasic.PCAN_PARAMETER_ON)

result = a.Initialize(chA, baudrate, hardwaretype, PCANBasic.c_uint(0), PCANBasic.c_ushort(0)) # init channel

# check if chA is in LISTEN_ONLY mode
print 'LISTEN_ONLY-Modus: %d' % (a.GetValue(chA, PCANBasic.PCAN_LISTEN_ONLY)[1])

msg.ID = 15
msg.LEN = 2
msg.DATA[0], msg.DATA[1] = 1,5
a.Write(chA, msg)

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: PCANBasic: problem using LISTEN_ONLY mode

Post by K.Wagner » Fri 9. Mar 2012, 08:46

Hello,
A.Kapp wrote:However, a following CAN_Send command still sends a message (cf. code snippet).
I check the message queue with PCAN-View (version 3.1.5.200) which is started after the channel has already been initialized.
If the PCAN-View is connected to the same Channel as your PCAN-Basic Application, then you will see the messages sent from your application; this is normal. Since those messages are from the same PCAN-Net (see "Additional Information/PCAN Fundamentals" in the Help document) all connected clients can see the "internal" messages. But the messages actually not go out to your physical CAN.

If you have more than one PCAN-Hardware, you can test this following these steps:
  1. Physically connect two hardware with a CAN cable.
  2. Connect a PCAN-View to each hardware
  3. Connect your PCAN-Basic application to one of the hardware
  4. Configure the LISTEN_ONLY and send a couple of messages
At this point, one PCAN-View should show received messages (that connected to the same hardware as your app) and the other doesn't.
Best regards,
Keneth

Post Reply