Moxa W341-LX Руководство по программной части онлайн [3/80] 171180
Table of Contents
1. Introduction ...................................................................................................................................... 1-1
Overview ........................................................................................................................................... 1-2
Software Architecture .......................................................................................................................... 1-2
Journaling Flash File System (JFFS2) ............................................................................................. 1-3
Software Package ........................................................................................................................ 1-4
2. Getting Started.................................................................................................................................. 2-1
Accessing the W321/341 Using a PC ..................................................................................................... 2-2
Serial Console ............................................................................................................................. 2-2
SSH Console ............................................................................................................................... 2-2
Configuring the Ethernet Interface ........................................................................................................ 2-3
Modifying Network Settings with the Serial Console ......................................................................... 2-3
Temporarily Modifying Networking Configurations ............................................................................ 2-4
Configuring the WLAN ......................................................................................................................... 2-4
Using WPA_SUPPLICANT to configure WPA2 ................................................................................... 2-5
SD Slot and USB for Storage Expansion ............................................................................................... 2-11
Test Program—Developing Hello.c ....................................................................................................... 2-13
Installing the Tool Chain (Linux) .................................................................................................. 2-13
Checking the Flash Memory Space ............................................................................................... 2-13
Compiling Hello.c ...................................................................................................................... 2-14
Uploading and Running the “Hello” Program ................................................................................. 2-14
Developing Your First Application ........................................................................................................ 2-15
Testing Environment .................................................................................................................. 2-15
Compiling tcps2.c ...................................................................................................................... 2-15
Uploading and Running the “tcps2-release” Program ...................................................................... 2-16
Testing Procedure Summary ....................................................................................................... 2-17
3. Managing Embedded Linux ................................................................................................................ 3-1
System Version Information ................................................................................................................. 3-2
System Image Backup ......................................................................................................................... 3-2
Upgrading the Firmware ............................................................................................................... 3-2
Loading Factory Defaults .............................................................................................................. 3-5
Enabling and Disabling Daemons .......................................................................................................... 3-5
Setting the Run-Level .......................................................................................................................... 3-7
Adjusting the System Time .................................................................................................................. 3-8
Setting the Time Manually ............................................................................................................ 3-8
NTP Client .................................................................................................................................. 3-8
Updating the Time Automatically ................................................................................................... 3-9
Cron—Daemon to Execute Scheduled Commands ................................................................................. 3-10
Connecting Storage Peripherals .......................................................................................................... 3-11
4. Managing Communications ............................................................................................................... 4-1
FTP ................................................................................................................................................... 4-2
SFTP ................................................................................................................................................. 4-2
DNS .................................................................................................................................................. 4-2
IPTABLES .......................................................................................................................................... 4-3
NAT .................................................................................................................................................. 4-7
NAT Example .............................................................................................................................. 4-8
Enabling NAT at Bootup ............................................................................................................... 4-8
Dial-up Service—PPP ........................................................................................................................... 4-9
PPPoE .............................................................................................................................................. 4-12
NFS (Network File System) ................................................................................................................ 4-14
Setting up the W321/341 as an NFS Client ................................................................................... 4-14
SNMP .............................................................................................................................................. 4-14
OpenVPN ......................................................................................................................................... 4-16
5. Tool Chains for Application Development .......................................................................................... 5-1
Linux Tool Chain ................................................................................................................................. 5-2
Steps for Installing the Linux Tool Chain ........................................................................................ 5-2
Compilation for Applications .......................................................................................................... 5-2
6. Programmer's Guide ......................................................................................................................... 6-1
Flash Memory Map .............................................................................................................................. 6-2
Device API ......................................................................................................................................... 6-2
RTC (Real Time Clock) ......................................................................................................................... 6-2
Buzzer ............................................................................................................................................... 6-2
WDT (Watch Dog Timer) ...................................................................................................................... 6-3
Digital Input/Output(W321 only) .......................................................................................................... 6-6
Application Programming Interface ................................................................................................ 6-6
DI/DO Program Makefile Example ................................................................................................ 6-10
UART .............................................................................................................................................. 6-11
Содержание
- Eleventh edition may 2013 1
- W321 341 linux software manual 1
- Www moxa com product 1
- Copyright notice 2
- Disclaimer 2
- Technical support contact information 2
- Trademarks 2
- W321 341 linux software manual 2
- Www moxa com support 2
- Introduction 5
- Overview 6
- Software architecture 6
- W321 341 linux introduction 6
- Journaling flash file system jffs2 7
- W321 341 linux introduction 7
- Software package 8
- W321 341 linux introduction 8
- Getting started 9
- Accessing the w321 341 using a pc 10
- Attention 10
- Serial console 10
- Ssh console 10
- Windows users 10
- Cd etc network 11
- Configuring the ethernet interface 11
- Linux users 11
- Modifying network settings with the serial console 11
- Root bee_notebook root ssh 192 68 27 the authenticity of host 192 68 27 192 68 27 can t be established rsa key fingerprint is 8b ee ff 84 41 25 fc cd 2a f2 92 8f cb 1f 6b 2f are you sure you want to continue connection yes no yes_ 11
- Ssh 192 68 27 11
- To change to the networking configuration directory 11
- Vi interfaces 11
- W321 341 linux getting started 11
- Configuring the wlan 12
- Esc w enter 12
- Etc init d networking restart 12
- Etc network interface 12
- Ifconfig eth0 192 68 7 15 12
- Iwpriv wlan0 get_site_survey 12
- Temporarily modifying networking configurations 12
- W321 341 linux getting started 12
- Connecto to an ap via wep shared key authentication 13
- Using wpa_supplicant to configure wpa2 13
- Connecting to an ap via wpa wpa2 psk authentication 14
- Etc init d wireless sh star 14
- Etc init d wireless sh sto 14
- Http www daemon systems org man wpa_supplicant conf html 14
- W321 341 linux getting started 14
- Configuring sta for ad hoc mode using wep 15
- W321 341 linux getting started 15
- Configuring sta for ad hoc mode using wpa none psk authentication 16
- Etc init d wireless sh star 16
- Etc init d wireless sh sto 16
- Etc init d wireless sh stop 16
- W321 341 linux getting started 16
- Http www daemon systems org man wpa_supplicant conf html http linux die net man 5 wpa_supplicant conf 17
- W321 341 linux getting started 17
- Adding wep setting into configuration file 18
- Adding wpa wpa2 settings into the configuration file 18
- Enabling wpa_cli to interact with wpa_supplicant 18
- Http linux die net man 8 wpa_cli 18
- Scanning ap and checking results 18
- W321 341 linux getting started 18
- Sd slot and usb for storage expansion 19
- W321 341 linux getting started 19
- W321 341 linux getting started 20
- Checking the flash memory space 21
- Installing the tool chain linux 21
- Mount dev cdrom mnt cdrom mnt cdrom tool chain arm linux_3 _build_11111411 sh 21
- Path usr local arm linux 4 bin path 21
- Test program developing hello c 21
- W321 341 linux getting started 21
- Cd example w321 hello make 22
- Cd tmp mkdir example cp r mnt cdrom example w321 tmp example 22
- Chmod x hello release hello release 22
- Compiling hello c 22
- Dev mtdblock 22
- Ftp 192 68 27 22
- Home and etc 22
- Put hello release 22
- Root localhost hello make usr local arm linux bin arm linux gcc o hello release hello c usr local arm linux bin arm linux strip s hello release usr local arm linux bin arm linux gcc ggdb o hello debug hello c root localhost hello _ 22
- Uploading and running the hello program 22
- W321 341 linux getting started 22
- Compiling tcps2 c 23
- Developing your first application 23
- Root moxa hello release hello 23
- Testing environment 23
- W321 341 linux getting started 23
- Uploading and running the tcps2 release program 24
- 68 27 putty 1 running tcps2 release root moxa ps pid uid vmsize stat command 1 root 532 s init 3 2 root swn ksoftirqd 0 3 root sw events 0 4 root sw khelper 13 root sw kblockd 0 14 root sw khubd 24 root sw pdflush 25 root sw pdflush 27 root sw aio 0 26 root sw kswapd0 604 root sw mtdblockd 609 root sw pccardd 611 root sw pccardd 625 root swn jffs2_gcd_mtd3 673 root 500 s bin inetd 682 bin 380 s bin portmap 685 root 1176 s bin sh login 690 root 464 s bin snmpd 714 root 1176 s bash 727 root 1164 s bash 728 root 1264 s tcps2 release 729 root 1592 s ps root moxa 25
- Kill 9 728 25
- Root moxa ls al drwxr xr x 2 root root 0 jun 12 02 14 drwxr xr x 15 root root 0 jan 1 1970 rw 1 root root 899 jun 10 08 11 bash_history rwxr xr x 1 root root 4996 jun 12 02 15 tcps2 release root moxa tcps2 release 1 187 start 25
- Tcps2 release 25
- Telnet 192 68 27 400 25
- Testing procedure summary 25
- W321 341 linux getting started 25
- W321 341 linux getting started 26
- Managing embedded linux 27
- 68 27 putty root moxa kversion w321 lx ersion 3 root moxa kversion a w321 lx version 3 build 13031118 28
- Attention 28
- Kversion 28
- System image backup 28
- System version information 28
- Upgrading the firmware 28
- W321 341 linux managing embedded linux 28
- 68 27 putty root moxa df filesystem 1k blocks used available use mounted on dev root 8192 7664 528 94 none 4096 8 4088 0 dev dev ram0 499 17 457 4 var dev mtdblock3 6144 588 5556 10 tmp dev mtdblock3 6144 588 5556 10 home dev mtdblock3 6144 588 5556 10 etc dev mmcblk0p1 479836 26993 428069 6 var mmc tmpfs 16384 0 16384 0 dev shm root moxa upramdisk root moxa df h filesystem size used available use mounted on dev root 8 m 7 m 528 k 94 none 4 m 8 k 4 m 0 dev dev ram0 499 k 18 k 456 k 4 var dev mtdblock3 6 m 588 k 5 m 10 tmp dev mtdblock3 6 m 588 k 5 m 10 home dev mtdblock3 6 m 588 k 5 m 10 etc dev mmcblk0p1 468 m 26 m 418 m 6 var mmc tmpfs 16 m 0 16 m 0 dev shm dev ram1 16 m 132 k 15 m 1 var ramdisk root moxa cd mnt ramdisk root moxa mnt ramdisk 29
- Cd mnt ramdisk 29
- Upramdisk 29
- W321 341 linux managing embedded linux 29
- Attention 30
- Upgradehfm 30
- W321 341 linux managing embedded linux 30
- Enabling and disabling daemons 31
- Loading factory defaults 31
- Cd etc rc d init d 33
- Cd etc rc d rc3 d 33
- Ln s etc rc d init d tcps2 s60tcps2 33
- Root 1852 s tcps2 release 33
- Root 1924 s bin snmpd 122 root 4316 s bin sshd 6 f etc ssh sshd_config 132 root 4316 s bin sshd 4 f etc ssh sshd_config 161 root 6928 s sshd root pts 0 163 root 2864 s bash 214 root 0 sw flush 1 0 215 root 0 sw flush 1 1 33
- Root 3096 r ps root moxa 33
- Setting the run level 33
- W321 341 linux managing embedded linux 33
- 68 27 putty 34
- Adjusting the system time 34
- Date mmddhhmmyyyy 34
- Hwclock 34
- Hwclock w 34
- Ntp client 34
- Ntpdate 192 68 7 34
- Rm f etc rc d rc3 d s60tcps2 34
- Setting the time manually 34
- W321 341 linux managing embedded linux 34
- Bin sh ntpdate time nist gov you can use the time server s ip address or domain name directly if you use domain name you must enable the domain client on the system by updating etc resolv conf file hwclock systohc sleep 100 updates every 100 seconds the min time is 100 seconds change 100 to a larger number to update rtc less often 35
- Ntp 2345 respawn etc init d fixtime 35
- Updating the time automatically 35
- W321 341 linux managing embedded linux 35
- 8 root homefixtime sh 36
- Bin sh ntpdate time nist gov hwclock systohc exit 0 36
- Chmod 755 fixtime sh 36
- Cron daemon to execute scheduled commands 36
- Etc init d cron start 36
- W321 341 linux managing embedded linux 36
- Connecting storage peripherals 37
- W321 341 linux managing embedded linux 37
- Attention 38
- W321 341 linux managing embedded linux 38
- W321 341 linux managing embedded linux 39
- Managing communications 40
- 3 00 putty root moxa etc cat resolv conf resolv conf this file is the resolver configuration file see resolver 5 nameserver 192 68 6 nameserver 168 5 nameserver 140 15 1 nameserver 140 15 36 0 41
- Discard dgram udp wait root bin discard discard stream tcp nowait root bin discard telnet stream tcp nowait root bin telnetd ftp stream tcp nowait root bin ftpd l 41
- Etc hosts 41
- Etc resolv conf 41
- Nameserver 168 5 41
- W321 341 linux 41
- Etc nsswitch conf 42
- Iptables 42
- W321 341 linux 42
- W321 341 linux 43
- Iptables iptables restore iptables save 44
- Lsmod modprobe ip_tables modprobe iptable_filter 44
- Modprobe iptable_filter 44
- W321 341 linux 44
- Define policy for chain rules 45
- Iptables f iptables x iptables z 45
- Iptables l n 45
- Iptables p input drop iptables p output accept iptables p forward accept iptables t nat p prerouting accept iptables t nat p output accept iptables t nat p postrouting accept 45
- Iptables t tables fxz 45
- Iptables t tables l n 45
- Iptables t tables p input output forward prerouting output postrouting accept drop 45
- Observe and erase chain rules 45
- W321 341 linux 45
- Append or delete rules 46
- Ipt_mac 46
- Iptables a input i eth0 p all m mac mac source 01 02 03 04 05 06 j drop 46
- Iptables a input i eth0 p tcp dport 21 j drop 46
- Iptables a input i eth0 p tcp s 192 68 24 j accept 46
- Iptables a input i eth0 p tcp s 192 68 4 dport 137 139 j accept 46
- Iptables a input i eth0 p tcp s 192 68 5 j drop 46
- Iptables a input i eth0 p tcp s 192 68 j accept 46
- Iptables a input i lo j accept 46
- Iptables t table ai input output forward io interface p tcp udp icmp all s ip network sport ports d ip network dport ports j accept drop 46
- W321 341 linux 46
- Enabling nat at bootup 47
- Nat example 47
- Dial up service ppp 48
- Example 1 connecting to a ppp server over a simple dial up connection 48
- Example 2 connecting to a ppp server over a hard wired link 49
- How to check the connection 49
- Netstat nr 50
- Ping z z z z 50
- Pppd dev ttym0 115200 crtscts modem 192 68 6 192 68 6 login auth 50
- Setting up a machine for incoming ppp connections 50
- W321 341 linux 50
- Pppd dev ttym0 115200 crtscts modem 192 68 6 192 68 6 51
- W321 341 linux 51
- W321 341 linux 52
- Mkdir p home nfs public mount t nfs nfs_server ip directory mount point 53
- Mount t nfs 192 68 00 home public home nfs public 53
- Nfs network file system 53
- Setting up the w321 341 as an nfs client 53
- W321 341 linux 53
- W321 341 linux 54
- Enable openvpn driver 55
- Mknod dev net tun c 10 200 55
- Openvpn 55
- Root moxa modprobe tun 55
- Setup 1 ethernet bridging for private networks on different subnets 55
- W321 341 linux 55
- Openvpn config a tap0 br conf openvpn config b tap0 br conf 59
- Openvpn show ciphers openvpn show auths 59
- Point to the peer remote 192 68 73 dev tap0 secret etc openvpn secrouter key cipher des ede3 cbc auth md5 tun mtu 1500 tun mtu extra 64 ping 40 up etc openvpn b tap0 br sh 59
- Route add net 192 68 netmask 255 55 55 dev eth0 59
- Start bin sh value after net is the subnet behind the remote peer route add net 192 68 netmask 255 55 55 dev br0 end 59
- Tun mtu extra 64 ping 40 up etc openvpn a tap0 br sh 59
- W321 341 linux 59
- Killall term openvpn 60
- Ping 192 68 74 60
- Route add net 192 68 netmask 255 55 55 dev eth0 60
- Setup 2 ethernet bridging for private networks on the same subnet 60
- Setup 3 routed ip 60
- W321 341 linux 60
- Point to the peer remote 192 68 74 dev tun secret etc openvpn secrouter key cipher des ede3 cbc auth md5 tun mtu 1500 tun mtu extra 64 ping 40 ifconfig 192 68 73 192 68 74 up etc openvpn a tun sh 61
- Remote 192 68 73 dev tun secret etc openvpn secrouter key cipher des ede3 cbc auth md5 tun mtu 1500 tun mtu extra 64 ping 40 ifconfig 192 68 74 192 68 73 up etc openvpn b tun sh 61
- Start bin sh value after net is the subnet behind the remote peer route add net 192 68 netmask 255 55 55 gw 5 end 61
- W321 341 linux 61
- Tool chains for application development 62
- Arm linu 63
- Arm linux gc 63
- Arm linux gcc o example wall g o2 example c arm linux strip s example arm linux gcc ggdb o example debug example c 63
- Compilation for applications 63
- Export path usr local arm linux 4 bin path 63
- I386 linux 63
- Linux tool chain 63
- Mount dev cdrom mnt cdrom 63
- Sh mnt cdrom tool chain w321 arm linux_3 _build_11111411 sh 63
- Steps for installing the linux tool chain 63
- W321 341 linux tool chains for application development 63
- Programmer s guide 64
- Buzzer 65
- Device api 65
- Flash memory map 65
- Int ioctl fd rtc_rd_time struct rtc_time time 65
- Int ioctl fd rtc_set_time struct rtc_time time 65
- Int ioctl int d int request input int d open device node return file handle int request argument in or out 65
- Man ioctl 65
- Rtc real time clock 65
- W321 341 linux programmer s guide 65
- All drivers that have an ioctl interface support at least one ioctl 66
- Int timeout 45 66
- Ioctl fd kdmktone unsigned int arg 66
- Ioctl fd wdioc_keepalive 0 ioctl fd wdioc_keepalive 0 66
- Ioctl fd wdioc_settimeout timeout 66
- Keepalive this ioctl does exactly the same thing as a write to the 66
- Printf the timeout was set to d seconds n timeout 66
- Replaced with 66
- Sleep 10 sleep 10 66
- The argument to the ioctl is ignored 66
- W321 341 linux programmer s guide 66
- Watchdog device so the main loop in the above program could be 66
- Wdt watch dog timer 66
- While 1 while 1 66
- Ioctl fd wdioc_gettimeout timeout 67
- Printf the timeout was is d seconds n timeout 67
- This example might actually print the timeout was set to 60 seconds 67
- W321 341 linux programmer s guide 67
- Int fd open dev watchdog o_wronly 68
- Int main void 68
- Int ret 0 68
- W321 341 linux programmer s guide 68
- Application programming interface 69
- Close fd 69
- Digital input output w321 only 69
- Exit exit_failure 69
- If fd 1 69
- If ret 1 69
- Perror watchdog 69
- Ret write fd 0 1 69
- Return ret 69
- Sleep 10 69
- While 1 69
- W321 341 linux programmer s guide 70
- Examples 71
- Special note 71
- W321 341 linux programmer s guide 71
- W321 341 linux programmer s guide 72
- Di do program makefile example 73
- W321 341 linux programmer s guide 73
- Example to get the baudrate 74
- Example to set the baudrate 74
- You must 74
- Baudrate inaccuracy 75
- Example 75
- Follow the standard termios baud rate define else ioctl fd moxa_get_special_baud_rate speed 75
- Relay output w341 only 75
- Special note 75
- W321 341 linux programmer s guide 75
- W321 341 linux programmer s guide 76
- Software lock 77
- Editor 78
- File manager 78
- Linux normal command utility collection 78
- System commands 78
- Modules 79
- Network 79
- Process 79
- W321 341 linux system commands 79
- Moxa special utilities 80
- W321 341 linux system commands 80
Похожие устройства
- Moxa W341-LX Технические характеристики
- Moxa W341-LX Руководство по аппаратной части
- Moxa W341-LX Руководство по работе с утилитой Moxa Device Manager
- Moxa W315A-LX Инструкция по эксплуатации
- Moxa W315A-LX Руководство по программной части
- Moxa W315A-LX Технические характеристики
- Moxa W315A-LX Руководство по аппаратной части
- Moxa W315A-LX Руководство по работе с утилитой Moxa Device Manager
- Moxa W325A-LX Инструкция по эксплуатации
- Moxa W325A-LX Руководство по аппаратной части
- Moxa W325A-LX Технические характеристики
- Moxa W325A-LX Руководство по программной части
- Moxa W325A-LX Руководство по работе с утилитой Moxa Device Manager
- Moxa W406-LX Инструкция по эксплуатации
- Moxa W406-LX Руководство по программной части
- Moxa W406-LX Руководство по аппаратной части
- Moxa W406-LX Технические характеристики
- Moxa W406-LX Руководство по созданию резервированных сетей
- Moxa W406-T-LX Инструкция по эксплуатации
- Moxa W406-T-LX Руководство по аппаратной части