horch - the Linux CAN analyser and CAN Server
|
horch is a simple network anlyser or if started in server mode, an CAN server which can be accessed network wide using a TCP/IP connection
horch is a command line application started with different options and arguments
horch [dtSTV] [-D dev][[-a] -b baud][-C -c id][-l file][-p port][-s time] Command line options -a - advanced - use >baud< as BTR0/1 value -b baud - use this baud rate at CAN (in KBit/s, standard 125) -C - interpret message id given with -c as debug message -c<id> - use id as debug id -d - debug mode, useful for program developer -l<file> - Log filename, logging is enabled/disabled with 'l' -p<n> - use portnumber in Server mode, default 7235 -s<time> - cyclic state display (ms) -t - show time stamp at start up -D device - CAN device Name, (z.B can1 LINUX) -S - TCP/IP Server Mode -T - use OS time not drivers time stamp -V - Version -C - occupy console focus
If specified, the baud value given with -b is used to set directly the bit-timing registers BTR0 and BTR1. Low byte is used for BTR0.
horch -ab 0x13c
used baud rate in kbaud. Without this option the driver is opened with the value from the file /proc/sys/dev/Can/Baud (LINUX can4linux)
Switch debug mode on. Messages about internal states and program flow are printed to stderr .
The CAN message ID given as an argument to the -c option gets a special interpretation if the option -C is set. Its content is interpreted and displayed as an ASCII character stream. CAN applications gets the opportunity to send text messages, e.g. debugging messages via CAN. Debug texts are prepended by the string DEBUG: .
The formatted display output can be saved in a local file. It's default name is logfile . With this option it is possible to set a new log-file name. Logging is activated sending a interactive command (see there) to horch . Logfiles are not created in Server mode.
The internet protocol uses the .port number to address a specific service on an server host. This is port number 7235 for horch . The port number can be set at at start time with this option.
Display CAN controller status information every <time> ms.
By default displaying of the time stamp is disabled at start up. It can be enabled interactively (see interactive commands). With this option given, it is enabled at start up. In this case time stamp format 1 is used, displaying Unix epoch time in seconds.
Selection of the used CAN channel (LINUX and Windows driver). device is the used device name for the selected channel. Using can4linux the device /dev/device is used. The can4linux device driver has to be installed befor calling horch .
Using horch in the TCP/IP server mode. This server is reachable within the local host as localhost , or within a TCP/IP network with the name of the hosted computer and the port number 7235. All commands to horch can be given over socket streams. For the command mode the server can also be reached with the common telnet application.
telnet host 7235
Telnet should be used with "character mode". In this mode commands are getting immediately effective. Set this mode once telnet ist started:
telnet> mode character
use operating system time as time stamp. By default horch uses the time stamp provided by the driver at receive time. If the driver does not support time stamps, the operating system time can be used. Usually this time is not the receive time, rather the display time.
prints the version number to stdout .
Received CAN Messages are displayed as ASCII text strings. The basic format description is:
[timestamp] <id-dec>/0x<id-hex> : <type> : 0{<data>}8 type: <frametype> + <datatype> datatype: D|R data or remote frame frametype x|b extended or base format frame example: 991330039.943806 12/0x00c : bD : 80 12 34 0d 991330039.944806 12/0x00c : xD : 80 12 34 0d 991330039.945806 4660/0x1234 : xR : (length=0) 991330039.946806 4660/0x1234 : xD : 01 02 03 04 05 06 991330039.947806 4660/0x1234 : xR : (length=4)
The message ID is always displayed in decimal and hex format. The leading time stamp value is optional and can be activated by an interactive command. Different time stamp formats are selectable with the interactive option o command. The format of the displayed data bytes can be selected by interactive commands too, from decimal, hex or ascii characters. Other messages are starting with:
ERROR: errors reported by horch or the CAN driver DEBUG: debugging text streams received by horch INFO: other information
horch can be controlled through commands from it's stdin channel (console or TCP/IP). Most commands consist of one letter and are used to change formatting of CAN messages. In the case stdin comes from the console horch uses the command stty (1) to switch the console int the raw, noecho mode.
On-line help, command overview All lines are prepended with the word INFO: at the start of line.
Formatting of data bytes as ASCII characters
change bit rate on-line
b 125
Every valid CANopen bit rate value is allowed
print a cut-mark line to stdout
Formatting of data bytes as decimal numbers
Installes a filter for received messages. For the format of filter specification see command option -f.
Formatting of data bytes as hex numbers
On LINUX Systems a interpreter program can be startet which interprets and displays the content of the actual logfile .
toggles state of local file logging. Logfiles are not created in Server mode.
Set the content of acceptance and mask register of the SJA1000 CAN controller chip. With the help of this command a message filter based on the CAN chip hardware is possible. (see SJA1000 documentation)
acc_code and acc_mask can be a 32 bit value as decimal or hexadecimal number.
set special can4linux options The argument that has to be given to this command is a set of bit flags. These bits can configure the can4linux by issuing ioctl () commands. the possible bits are
bit | x |
---|---|
[0] | if set, switch on self-reception of transmitted frames |
[1] | if set, switch on listen only mode (don't acknowledge CAN frames) |
[3:2] | select the time stamp format |
0 - time stamp off (displays 0.0) | |
1 - standard time stamp as Unix epoch in s.µs | |
2 - absolute time as of start of the system in s.µs | |
3 - relative time to the previous received frame in s.µs |
quit program
Reset the CAN controller, e.g. after a Error Busoff.
reset the values of horch statistic variables.
display statistic informations
There is noting like a standard format. The information displayed may depend on the used CAN controller of the CAN Layer-2 driver. The first column displays always the name of the used CN controller, followed by special CAN controller register contents. For the most often used CAN controller SJA1000 a statistic line looks like this:
:: sja1000 <act baud rate> <status register> <error_warning limit> <rx errors> <tx errors> <error code> <buslast>
activate display of time stamps. The used format can be selected by the o command.
deactivate display of time stamps.
activates a CAN message trigger. Trigger conditions have to be set before using this command.
stop the CAN message trigger
change trigger settings. Format is
x idx mask [r] id [data]
send a CAN message via horch .
A CAN message is sent. All of the letters following the command letter are interpreted as arguments. The capital command letter W is used to send in extended frame message format (using 29 bits) If the letter r is following the command letter as first argument, an RTR message is sent.
w [r] id 0{data}8 w 222 0xaa 0x55 100 ; standard message with three data bytes w r 0x100 0 0 0 ; standard rtr message with data length code 3 W 0x100 1 2 ; extended message with two data bytes
Formattting of data bytes as hex numbers. Opposite to the h command letter, CAN message data are stored as binary data as canmsg_t structure if local file logging is enabled (-l ). All other formats are stored as ASCII character lines.
<id> <id> which should be received <id 1>-<id 2> <id 1> tos <id 2> schould be received <id>- tarting from <id> all messages are received -<id> up to <id> messages should be received <id>,<id 1>,<id 2> are inclusive, belonging to the selected range
Format:
x idx mask [r] id [data]
idx is a value between 0 and 2 and specifies a trigger buffer. mask specifies which bytes are don't care bytes. If the 2nd parameter is r, so the trigger waits for a RTR Message. id is selected CAN-ID starting the trigger condition. data are the optional data bytes of the message
Errors recognized by the driver are displayed at the console as text messages. The following messages are known:
Error message | meaning |
---|---|
"ERROR: OVERRUN" | CAN chip overrun |
"ERROR: PASSIVE" | Error passive |
"ERROR: BUSOFF" | Error Busoff (use command R for Bus on) |
"ERROR: Buffer OVERRUN" | Software buffer overrun |