INNO USB-CAN MODULE User Manual Download Page 7

Design Service,Production Service

www.inno-maker.com

Support:

[email protected] www.inno-maker.com/wiki

Bulk Price:

[email protected]

7

2. Linux C Programing

Now with previous demo’s code to show you how to program socket can in linux. The socket

can is an implementation of CAN protocols(Controller Area Network) for Linux. CAN is a
networking technology which has widespread use in automation, embedded devices, and
automotive fields. While there have been other CAN implementations for Linux based on
character devices, Socket CAN uses the Berkeley socket API, the Linux network stack and
implements the CAN device drivers as network interfaces. The CAN socket API has been designed
as similar as possible to the TCP/IP protocols to allow programmers, familiar with network
programming, to easily learn how to use CAN sockets.

(1) Preparations:

Elimination the need for software drivers when you run Debian9 system of Raspberry

Pi.(2018-06-27-raspbian-stretch.img is validated already)or later.

If you meet problems in other system, You need to reconfigure the kernel drivers. Enable

gs_usb can and install gs_usb.ko into system. So notice that if you only compile this drivers, It
may fail to load in system. At this time, compile fully with new configure.

The compiled firmware with LINUX -4.14.50 version is available from our wiki link as below:

http://www.inno-maker.com/wiki/doku.php?id=usb_can

Or

http://www.inno-maker.com/wiki/

Note :You must use a TF card at least than 16Gb, Otherwise it will write failed.

(2) For Sender’s code:

Step 1: Create the socket, If an error occurs then the return result is -1.

Summary of Contents for USB-CAN MODULE

Page 1: ...Design Service Production Service www inno maker com Support support inno maker com www inno maker com wiki Bulk Price sales inno maker com 1 USB CAN MODULE User Manual...

Page 2: ...y experienced engineer interfacing to expensive industrial equipment yet simple enough for home use by an amateur hobbyist Features 1 Compatible with Raspberry Pi Zero Zero W 2B 3B 3B 2 Full support f...

Page 3: ...ce www inno maker com Support support inno maker com www inno maker com wiki Bulk Price sales inno maker com 3 Hardware Description 1 Pin Out Configuration 2 120 Ohm resistor setting Disable 120 Ohm r...

Page 4: ...s port and then insert into the USB Host of Raspberry PI board 2 Down the the demo image from INNO wiki page http www inno maker com wiki doku php id usb_can Or http www inno maker com wiki Note You m...

Page 5: ...ce www inno maker com Support support inno maker com www inno maker com wiki Bulk Price sales inno maker com 5 6 Set other Pi as sender execute following commands can0_send 7 You should see that the r...

Page 6: ...ki Bulk Price sales inno maker com 6 Run demo for only one Raspberry Pi In this case you also can insert two USB CAN module into a Raspberry PI board to test You should see two can socket can 0 and ca...

Page 7: ...r as possible to the TCP IP protocols to allow programmers familiar with network programming to easily learn how to use CAN sockets 1 Preparations Elimination the need for software drivers when you ru...

Page 8: ...iki Bulk Price sales inno maker com 8 Step 2 Locate the interface to can0 or other name you wish to use The name will show when you execute ifconfig a Step 3 Bind the socket to can0 Step 4 Disable sen...

Page 9: ...ki Bulk Price sales inno maker com 9 Step 6 Send message to the can bus You can use the return value of write to check whether all data has been sent successfully Step 7 Close can0 device and disable...

Page 10: ...can bus For more Socket CAN detail please refer to below link https www kernel org doc Documentation networking can txt Version Descriptions Version Description Author Date E mail V1 0 0 0 First edit...

Reviews: