Moxa UC-8416-T-LX [69/90] Moxa can programming guide

Moxa UC-8410-T-LX [69/90] Moxa can programming guide
UC-8410/8416/8418/8430 Programmer's Guide
5-17
CPP = xscale-linux-gcc
SOURCES = hello.c
OBJS = $(SOURCES:.c=.o)
all: hello
hello: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
clean:
rm -f $(OBJS) hello core *.gdb
Moxa CAN 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
IDusually chosen to identify the message-type/senderand 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;

Содержание

Скачать