Moxa IA261-I-T-LX [61/71] Moxacan programming guide

Moxa IA261-I-T-LX [61/71] Moxacan programming guide
IA260/IA261/IA262/EM-2260 Linux User’s Manual Programmer’s Guide
MoxaCAN Programming Guide
Introduction
CAN is a broadcast serial bus standard for connecting electronic control units (ECUs).
Each node is able to send and receive messages, but not simultaneously: a message (consisting
primarily of an ID—usually chosen to identify the message-type/sender—and up to eight message
bytes) is transmitted serially onto the bus, one bit after another. This signal-pattern codes the
message (in NRZ) and is sensed by all nodes.
Moxa embedded computers provide the CAN bus interface for industrial CAN communication.
Users can use the file control interface to read, write, or control the CAN interface as a file for
easy CAN programming.
Programming Guide
The CAN data format looks like this:
Define the structure for CAN programming as follows:
moxacan_ioctl.h
#ifndef _MOXACAN_IOCTL_H
#define _MOXACAN_IOCTL_H
#ifndef BIT
#define BIT(x) (1<<(x))
#endif // BIT
#define MAX_CAN_DATA_LENGTH 8
typedef union __attribute__ ((packed)) can_data_union {
unsigned char array[MAX_CAN_DATA_LENGTH];
struct byte_struct {
unsigned char byte1;
unsigned char byte2;
unsigned char byte3;
unsigned char byte4;
unsigned char byte5;
6-5

Содержание

Похожие устройства

Скачать