- Using the CAN232 dongle -
My CAN Software Download Site


Updated on 6/May/2006

The CAN232 dongle is manifactured by LAWICEL.
More product info on the dongle ( I am using the new version ) can be found here.
On the official CAN232 website, you can find sample codes ( Downloads ) and a dealer list as well.
It's an excellent little product with awesome support folks.

Information on my new CANUSB can be found at the bottom of this page.


All the below codes are written by me, in C, targeted for Linux.
They are free for grab, please see copyright notice on the bottom of this page.



Acceptance Register Calculations :
To compute the ACR and AMR registers of the SJA1000
CAN controller chip. This is important for filtering traffic.
You send these with the 'M' and 'm' messages to the CAN232.

Download the file acramr_calc.c.
Download the file acramr_calc_simple.c for single register.

I also found it useful to be able to tell what is filtered based on the ACR/AMR registers :

Download the file acramr_rev_calc.c.

Data Collector and Logger :
( To read the CAN traffic through the RS232 interface. )

I wrote a dual-buffer async reader, which forks to 2 processes,
one collecting the info the other saving it. There is also the possibility
of suspending the collection with 'z' and if you start the code with any
commandline parameter, the collection is suspended by default.
It also sends heartbeat info every second with the ID of 0xFFE ( tFFE0:dddddd )
and keypresses are also stored with 0xFFF + 0 byte lenght and 2 byte ASCII ( tFFF0:xx )
Download the file canpoll.c.
Also download the file cleanfile.c which cleans up the resulted ASCII file...
Here is a little "csv to myformat" csv2txt.c program I wrote to convert from Excel 'csv's...
( converts lines from '33,2.012232,0.00025,30,84,0,A0,0,0,20,0,DC' to 't03088400A000002000DC')

I usually use my graph editor to evaluate the data :

Download the files : canvis.tgz or canvis.zip
Usage is './canvis traffic_file'... using files that the canpoll.c file is producing...
Read the key assignments dumped in the beginning.

Other miscellaneous :
I needed to test, if my CAN controller is still OK, so I externally applied 12V
on the dongle, but did not connect to the CAN. The code below instructs the CAN232 to
put some bogus message on the not-connected CAN, so you should see the RED led going
crazy for 3 seconds. If there is LED activity, your CAN232 is fine...
Download the file cantest.c.
( I also use this program to change the UART settings, please see header... )


In case you can not set the UART on the dongle back to it's original
setting, use the below code and follow comments on how to do it :
Download the file canterminal.c.


I have written a practical application for my '04 Prius
to display some statistics while driving, using the CAN232 dongle.
On my Prius page, you can see some screenshots...
Download the zip'd file zaurus_graphcan.zip.
It has the Zaurus v9.0 binary file, all the mp3 files and the modified mp player.

Here is the graphcan.c source code, now working on X-Windows as well.
Look at the header of the file on how to compile...

Here is the DTCchk program for the Zaurus, which checks/clears
the trouble codes. Use 'DTCchk check' or 'DTCchk clear'.



- Working with the CANUSB -

The
CANUSB is also manifactured by Lawicel and overcomes
the speed limitations set by using the serial port. Making it run
under Linux required a little bit of tweaking, besides the published
solution on the CANUSB Linux website, here is my
- probably - hard-core one :
BASICS :

1.) You need to edit and recompile the ftdi_sio kernel object.
 This can be done either in a "hacker" fashion or in a "developer" fasion :

 HACKER one ( just use hard-coded data ) :
 - Locate the ftdi_sio.c file in the kernel source directory.  ( /usr/src/kernel###/drivers/usb/serial )
 - Add to ftdi_sio.c the following line in the "static struct usb_device_id id_table_combined [] = {" definition :
	{ USB_DEVICE(0x0403, 0xFFA8) },	// Added for CANUSB

 DEVELOPER one ( with .h and symbols ) :
 You need to add 1 lines in the ftdi_sio.[ch] files.
 - Locate the ftdi_sio.c and ftdi_sio.h files in the kernel source directory. ( /usr/src/kernel###/drivers/usb/serial )
 - Add to ftdi_sio.h the following, anywhere :
 #define FTDI_LAWICEL_CANUSB_PID  0xFFA8
 - Add to ftdi_sio.c the following line in the "static struct usb_device_id id_table_combined [] = {" definition :
	{ USB_DEVICE(FTDI_VID, FTDI_LAWICEL_CANUSB_PID) },	// Added for CANUSB
   ( Since FTDI_VID is already "0x0403" )

 Recompile and install the module.
 (It should be transferred to /lib/modules/#version#/kernel/drivers/usb/serial/   as "ftdi_sio.ko" in my 2.6 Debian case )


2.) Add to /etc/hotplug/usb.handmap :
 ftdi_sio   0x0003 0x0403 0xffa8 0x0000 0x0000 0x00 0x00 0x00 0xff 0x00 0x00 0x0


3.) CANUSB will show up on /dev/ttyUSB[012..] and the original USB232 code can be used, as things like baud setting does not apply...

You will need to take care of permissions for the /dev/ttyUSB0 if not running as root... Email me if you have problems.

Hmmm, looking at the above, the CANUSB one might be easier for non-experts...



Go to my Prius CAN project site...

Copyright (c) 2004 Attila Vass
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.








Site Meter