CANpro/104 Software Installation Guide for QNX6

Documentation
Original: Zhe Fang, 2008
Updated: March, 2010 Connect Tech Inc

Architecture

First of all, an explanation of the word CAN. CAN, stands for Controller Area Network, is only a kind of Network, just similar as those we’ve used in our daily life: LAN, WAN, etc. This driver suite is designed keeping this in mind. Thus it’s based on QNX Neutrino’s network architecture: io-net.

Currently there are 2 modules:
devn-sja1000 and npm-rawcan.

devn-sja1000 is used to deal with the hardware, the NXP SJA1000 chip. It turns everything from io-net’s packet to hardware operations, and vice versa.
npm-rawcan is used to deal with client applications. It interfaces clients through libsocket, the most widely used network API from BSD.

As in QNX Neutrino, libsocket is actually implemented to communicate with network stacks by sets of messages. So the npm-rawcan is both
a io-net module and a resource manager. It converts io-net’s packet to messages in the form that libsocket can read and vice versa.

Installing the CANpro/104 QNX 6 Driver

Caveat

Due to changes in the way io-net is handled in QNX 6.4, this driver does not work under it. To reiterate, this driver does not yet work under QNX 6.4.

Compile and Install

There’s a makefile under each module. Open a terminal and type

cd /the/directory
then
make; make install

This will automatically build the module and copy it to a right place where io-net can identify.

Note that the compiled binaries are included, so in most cases copying the files in /dll/ to /lib/dll will be sufficient to install.

Startup

devn-sja1000 requires some options to start up. Please ‘use /lib/dll/devn-sja1000.so’ for details and examples.

Examples

There are some example programs written for npm-rawcan. Take a look in them so you can test the driver functional. You may also want to take them as a reference when you’re writing your own.

Writing your own

The interface to socket functions is defined in npm-rawcan’s rawcan_client.h. Please notice that id is in specification’s format, which means you’ll have to convert an ordinal number into big endian and shift 21 bits left to get an id in standard form. There are a few helper macros if you want to use the extended form of id:

/* Convert a 29-bit, aligned-to-LSB ordinal number into an id in the format */
#define extid(i) ((ENDIAN_BE32(i) & 0x1ffc0000) << 3 | 0x18000 | (ENDIAN_BE32(i) & 0x3ffff) << 1)

/* Vice vesa: assert((i & 0x18000) == 0x18000) first! */
#define ordid(i) ENDIAN_BE32(((i) & 0xffe00000) >> 3 | ((i) & 0x7fffe) >> 1)

Keep in mind that the position of Remote Transmit Request bit is different in either mode. You may notice that there is a loopback function in npm-rawcan, which means client programs are alike working on a virtual CAN if they specify the same iface number in can_sockaddr struct. This helps writing programs even without any hardware (and devn-sja1000).

You may find it interesting to write an npm if you’re going to write a CAN based protocol, or something like CAN-LAN bridge. In this way you may need definitions in devn-sja1000’s io-net-can.h.

The usage of io-net’s packet is very simple:
1 iov with 1 buffer, with data right followed id. Set framelen to length of both, and don’t forget about cell and endpoint.

Go to Top