Moxa TC-SW04-M12-4P-T [27/43] Tc cp02 db t configuring the socket can interface
![Moxa TC-SW04-M12-8P [27/43] Tc cp02 db t configuring the socket can interface](/views2/1200485/page27/bg1b.png)
TC-6000 Series Expansion Modules Software Installation and Programming Guide
4-7
extends the Berkeley sockets API in Linux by introducing a new protocol family, PF_CAN, that coexists with
other protocol families like PF_INET for the Internet Protocol.
You can use the file control interface to read, write or control the CAN interface as a file for easy CAN
programming.
TC-CP02-DB-T: Driver Installation
The drivers for Moxa TC-SP04-DB44-T module include can.ko, can_raw.ko, can_bcm.ko, can_dev.ko,
sja1000.ko, and plx-pci.ko . These have all been pre-installed under:
/lib/modules/3.2.0-4-686-pae/updates/drivers/net/can
Some drivers will be loaded by the boot process when modules are inserted; others must be loaded manually,
using modprobe:
Moxa:~# modprobe can
Moxa:~# modprobe can_raw
Moxa:~# modprobe can_bcm
You may set modules to load automatically at boot by listing them in the /etc/modules file.
TC-CP02-DB-T: Configuring the Socket CAN Interface
After the modules have been loaded, the next step is to configure the CAN interface and start it as a standard
net interface. Here’s an example with bitrate 12500:
# ip link set can0 up type can bitrate 12500
# ip link set can1 up type can bitrate 12500
The SocketCAN information is stored under /proc/net/can; you can determine what version is being used by
using the cat command:
Moxa~:# cat /proc/net/can/version
and return usage/operating statistics thus:
Moxa~:# cat /proc/net/can/stats
TC-CP02-DB-T: Sample Script for the SocketCAN API
The following code is a working example of the SocketCAN API in use; this code sends a CAN packet using the
raw interface. It is based on the notes documented in the Linux Kernel
(https://www.kernel.org/doc/Documentation/networking/can.txt).
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <net/if.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/can.h>
#include <linux/can/raw.h>
int
main(void)
{
int s;
Содержание
- First edition july 2014 1
- Tc 6000 series expansion modules user s manual 1
- Www moxa com product 1
- Copyright notice 2
- Disclaimer 2
- Tc 6000 series expansion modules user s manual 2
- Technical support contact information 2
- Trademarks 2
- Www moxa com support 2
- Table of contents 3
- Introduction 4
- Available modules 5
- Overview 5
- Package checklist 5
- Tc 6000 series expansion modules introduction 5
- Can interface 6
- Environmental limits 6
- Mini pcie card 6
- Physical characteristics 6
- Serial communication parameters 6
- Serial port interface 6
- Tc 6000 series expansion modules introduction 6
- Tc 6000 series module specifications 6
- Tc cp02 db t specifications 6
- Tc dk10 t tc dk20 t specifications 6
- Tc sp04 db44 t specifications 6
- Environmental limits 7
- Ethernet interface 7
- Physical characteristics 7
- Sata interface 7
- Tc 6000 series expansion modules introduction 7
- Tc sata t specifications available on request 7
- Tc sw04 m12 4p t tc sw04 m12 8p t specifications 7
- Hardware introduction 8
- Appearance 9
- Tc 6000 series expansion modules hardware introduction 9
- Tc cp02 db t 9
- Tc dk10 t tc dk20 t 9
- Tc sp04 db44 t 9
- Tc 6000 series expansion modules hardware introduction 10
- Tc sata t 10
- Tc sw04 m12 4p t tc sw04 m12 8p t 10
- Dimensions 11
- Tc 6000 series expansion modules hardware introduction 11
- Hardware connection description 12
- Installing the tc 6000 series expansion modules 13
- Tc 6000 series expansion modules hardware connection description 13
- Connecting data transmission cables 14
- Rs 232 14
- Rs 422 4 wire rs 485 14
- Tc sp04 db44 t serial port module 14
- Tc 6000 series expansion modules hardware connection description 15
- Tc cp02 db t can bus module 15
- Wire rs 485 15
- Installing cellular modules on the tc dk10 t and tc dk20 t 16
- Tc 6000 series expansion modules hardware connection description 16
- Tc sw04 m12 4p t tc sw04 m12 8p t switch module 16
- Attention 17
- Installing a cellular module 17
- Tc 6000 series expansion modules hardware connection description 17
- Installing the ssd hdd into the tc sata module 18
- Tc 6000 series expansion modules hardware connection description 18
- Tc 6000 series expansion modules hardware connection description 19
- Tc 6000 series expansion modules hardware connection description 20
- Software installation and programming guide 21
- Installation of linux modules using apt 22
- Linux system peripherals programming guide 22
- Prerequisite for installing peripheral modules 22
- Attention 23
- Dev ttym 23
- Installing linux modules from the moxa website 23
- Lib modules 3 4 686 pae updates drivers tty mxser k 23
- Moxa apt get install package name 23
- Moxa apt get remove package name 23
- Moxa dpkg i package file 23
- Moxa dpkg r package file 23
- Mxser k 23
- Tc 6000 series expansion modules software installation and programming guide 23
- Tc sp04 db44 t serial port 23
- Ttym15 23
- Example script 1 setting the baudrate 24
- Example script 2 return the baudrate 24
- Non standard baudrates and baudrate inaccuracy 24
- Tc sp04 db44 t configuring the baudrate 24
- Warning 24
- 1 6 round to the nearest integer to get 7 25
- 1 96 1 25
- 1 then round down to the nearest integer to get 1 25
- Checking current serial settings 25
- Device node dev ttym0 dev ttym15 device node dev ttym0 dev ttym15 25
- Enum 8 25
- Factor 25
- Inaccuracy 25
- Interface no interface no following 25
- Moxa setinterface dev ttym0 2 moxa setinterface dev ttym0 25
- Moxa setinterface dev ttym0 now setting is rs485 2wires interface 25
- Moxa setinterface usage setinterface device node interface no 25
- None to view now setting none to view now setting 25
- Root formula inaccuracy 25
- Set to rs232 interface 0 set to rs232 interface 25
- Set to rs422 interface 2 set to rs422 interface 25
- Set to rs485 2wires interface 1 set to rs485 2wires interface 25
- Set to rs485 4wires interface 3 set to rs485 4wires interface 25
- Setinterfac 25
- Setinterface dev ttym0 0 25
- Setinterface device node interface option 25
- Target non standard baud rate 500 000 25
- Tc 6000 series expansion modules software installation and programming guide 25
- Tc sp04 db44 t configuring serial port modes 25
- Attention 26
- Etc udev rules d 96 moxa rule 26
- Moxa reboot 26
- Moxa rule 26
- Moxa setinterface dev ttym0 now setting is rs485 2wires interface 26
- Moxa umount 26
- Now setting is rs422 interface 26
- Run bin setinterface dev ttym n 26
- Run bin setinterface dev ttym n 0 26
- Run bin setinterface dev ttym n 2 26
- Run bin setinterface dev ttym n 3 26
- Set the device tc sp04 db44 t 0x1393 0x1042 default as 232 mode interface drivers mxser attrs vendor 0x1393 attrs device 0x1042 run bin setinterface dev ttym n 0 96 moxa rules 26
- Setinterfac 26
- Tc 6000 series expansion modules software installation and programming guide 26
- Tc cp02 db t can bus interface 26
- Etc module 27
- Int main void int s 27
- Ip link set can0 up type can bitrate 12500 ip link set can1 up type can bitrate 12500 27
- Lib modules 3 4 686 pae updates drivers net can 27
- Moxa modprobe can moxa modprobe can_raw moxa modprobe can_bcm 27
- Proc net ca 27
- Tc 6000 series expansion modules software installation and programming guide 27
- Tc cp02 db t configuring the socket can interface 27
- Tc cp02 db t driver installation 27
- Tc cp02 db t sample script for the socketcan api 27
- Mpcie power 0x27 1 0 30
- On off flag 30
- Tc 6000 series expansion modules software installation and programming guide 30
- Tc dk10 t tc dk20 t configuring power controls 30
- Tc dk10 t tc dk20 t mini pcie interface 30
- Warning 30
- Attention 31
- Tc 6000 series expansion modules software installation and programming guide 31
- Tc 6000 series expansion modules software installation and programming guide 32
- Tc sp04 db44 t driver installation 32
- Windows system 32
- Tc 6000 series expansion modules software installation and programming guide 33
- Tc sp04 db44 t configuring serial port mode 33
- Tc 6000 series expansion modules software installation and programming guide 34
- Tc 6000 series expansion modules software installation and programming guide 35
- Tc 6000 series expansion modules software installation and programming guide 36
- Tc 6000 series expansion modules software installation and programming guide 37
- Tc cp02 db t driver installation 37
- Tc 6000 series expansion modules software installation and programming guide 38
- Moxa can bus library 39
- Tc 6000 series expansion modules software installation and programming guide 39
- Tc cp02 db t can module programming guide 39
- Tc 6000 series expansion modules software installation and programming guide 40
- Tc 6000 series expansion modules software installation and programming guide 41
- Tc dk10 t tc dk20 t enabling disabling usb socket 41
- Tc 6000 series expansion modules software installation and programming guide 42
- Attention 43
- Tc 6000 series expansion modules software installation and programming guide 43
Похожие устройства
- Moxa TC-SW04-M12-4P-T Технические характеристики
- Moxa TC-SW04-M12-8P Инструкция по эксплуатации
- Moxa TC-SW04-M12-8P Технические характеристики
- Moxa TC-DK10-T Инструкция по эксплуатации
- Moxa TC-DK10-T Технические характеристики
- Moxa TC-DK20-T Инструкция по эксплуатации
- Moxa TC-DK20-T Технические характеристики
- Moxa EXPC-1519-C1-S1-T Инструкция по эксплуатации
- Moxa EXPC-1519-C1-S2-T Инструкция по эксплуатации
- Moxa EXPC-1519-C1-S3-T Инструкция по эксплуатации
- Moxa EXPC-1519-C7-S3-T Инструкция по эксплуатации
- Moxa EXPC-1519-C7-S2-T Инструкция по эксплуатации
- Moxa EXPC-1519-C7-S1-T Инструкция по эксплуатации
- Moxa EXPC-1319-STS-W7E Инструкция по эксплуатации
- Horizont 32LE3181 Руководство по эксплуатации
- Horizont 43LE5173D Руководство по эксплуатации
- Horizont 32LE5161D Руководство по эксплуатации
- Horizont 49LE5161D Руководство по эксплуатации
- Horizont 15LE3416 Руководство по эксплуатации
- Horizont 19LE5206D Руководство по эксплуатации