Chardev or Netdev driver compilation?

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
thorpey01
Posts: 8
Joined: Fri 26. Feb 2016, 10:55

Chardev or Netdev driver compilation?

Post by thorpey01 » Tue 15. Mar 2016, 15:42

Hi,

I am new to using PEAK CANBUSB Pro. I have successfully installed the device drivers under Ubuntu (14.04)
I would like to develop in Python read and write CAN messages .. I currently have built the device drivers with the option : make NET=NO .. so I have Chardev device drivers installed. I can successfully run the receive and transmit test so i know my device is running ok. I want to use Python to transmit on CAN Bus1 .. In CharDev drivers when I type cat /proc/pcan i get two interfaces no.s 32,33.


i have my code as follows: I don't know how to list the two CAN interfaces I have.. do I even need to install the NEtDev version of the driver in order to use with Python? So that I can have Netdev interfaces CAN1 and CAN2?


import sys
sys.path.append('''/home/rdm/peak-linux-driver-7.15.2/jdk1.8.0_73''')
#sys.path.append('''/home/rdm/peak''')

import PCANBasic

channel = PCAN_USBBUS1
baud = PCAN_BAUD_500K

# The Plug & Play Channel (PCAN-USB) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(channel, baud)
if result != PCAN_ERROR_OK:
# An error occured, get a text describing the error and show it
#
result = objPCAN.GetErrorText(result)
print(result[1])
else:
print("PCAN-USBx was initialized")

I'm pretty sure that the channel = PCAN_USBBUS1 is incorrect..

best regards,
Nicholas.

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Chardev or Netdev driver compilation?

Post by PEAK-Support » Wed 16. Mar 2016, 10:46

if you want to use our PCAN-Basic Interface API with Python you need to use the CharDev Driver.
So its a need to compile the PCAN-Basic LIB first to use the library in Python.

To run the Python sample you need the Tkinter package

Code: Select all

$ apt-get install python-tk
and the Tix
$ apt-get install Tix (TK extension library)
then run the sample (need GUI/X-Windows)
$ python PCANBasicExample.pyw
You also could use NETDEV (SocketCAN) driver - but then you need to search on the WEB for existing samples (they are available - but Socket CAN is supported by the community)
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply