background image

DA-710 Series Linux 

Managing Communications 

 

3-30 

2.

 

On machine OpenVPN A, modify the remote address in configuration file

 /etc/openvpn/tun.conf

# point to the peer 
remote 192.168.8.174 
dev tun 
secret /etc/openvpn/secrouter.key 
cipher DES-EDE3-CBC 
auth MD5 
tun-mtu 1500 
tun-mtu-extra 64 
ping 40 
ifconfig 192.168.2.173 192.168.4.174 
up /etc/openvpn/tun.sh 

3.

 

Next, modify the routing table in script file 

/etc/openvpn/tun.sh

#---------------------------Start---------------------------- 
#!/bin/sh 
# value after “-net” is the subnet behind the remote peer 
route add -net 192.168.2.0 netmask 255.255.255.0 gw $5 
#----------------------------end----------------------------- 

4.

 

On machine OpenVPN B, modify the remote address in configuration file 

/etc/openvpn/tun.conf

# point to the peer 
remote 192.168.8.173 
dev tun 
secret /etc/openvpn/secrouter.key 
cipher DES-EDE3-CBC 
auth MD5 
tun-mtu 1500 
tun-mtu-extra 64 
ping 40 
ifconfig 192.168.4.174 192.168.2.173 
up /etc/openvpn/tun.sh 

And then modify the routing table in script file 

/etc/openvpn/tun.sh

#--------------------------Start---------------------------- 
#!/bin/sh 
# value after “-net” is the subnet behind the remote peer 
route add -net 192.168.2.0 netmask 255.255.255.0 gw $5 
#---------------------------end----------------------------- 

The first argument of parameter 

ifconfig

 is the local internal interface and the second argument is the 

internal interface at the remote peer. 

$5

 is the argument that the OpenVPN program passes to the script file. Its value is the second argument of 

ifconfig

 in the configuration file. 

5.

 

Check the routing table after you run the OpenVPN programs, by typing the command 

# route

Destination  

Gateway  

 

Genmsk   

 

Flags  Metric  Ref Use Iface 

192.168.4.174  *   

 

 

255.255.255.255 UH   

0   

0  0  tun0 

192.168.4.0  

192.168.4.174  255.255.255.0  UG   

0   

0  0  tun0 

192.168.2.0  

*   

 

 

255.255.255.0  U   

0   

0  0  eth1 

192.168.8.0  

*   

 

 

255.255.255.0  U   

0   

0  0  eth0 

 
 

Summary of Contents for DA-710 Series

Page 1: ...DA 710 Series Linux User s Manual Second Edition August 2012 www moxa com product 2012 Moxa Inc All rights reserved ...

Page 2: ...s to this manual or to the products and or the programs described in this manual at any time Information provided in this manual is intended to be accurate and reliable However Moxa assumes no responsibility for its use or for any infringements on the rights of third parties that may result from its use This product might include unintentional technical or typographical errors Changes are periodic...

Page 3: ...r Expansion Modules 3 5 Serial Port Operation Mode 3 6 Telnet FTP Server 3 7 DNS Client 3 8 Apache Web Server 3 9 Default Homepage 3 9 Disabling the CGI Function 3 10 Saving Web Pages to a USB Storage Device 3 10 IPTABLES 3 12 IPTABLES Hierarchy 3 13 IPTABLES Modules 3 13 Observe and Erase Chain Rules 3 14 Define Policy for Chain Rules 3 15 Append or Delete Rules 3 15 NAT Network Address Translati...

Page 4: ...tive small footprint devices Software written for desktop PCs can be easily ported to the embedded computer with a GNU cross compiler and a minimum of source code modifications A typical Linux based device is designed for a specific use and is often not connected to other computers or a number of such devices connect to a centralized front end host Examples include enterprise tools such as industr...

Page 5: ... a standard 4U 19 inch wide rack mounted rugged enclosure This robust rack mountable design provides the hardened protection needed for industrial environment applications Software Specifications The Linux operating system pre installed on the DA 710 embedded computer is the Debian Lenny 5 0 distribution The Debian project is a worldwide group of volunteers who endeavor to produce an operating sys...

Page 6: ...ge bind9 host 1 9 5 1 dfsg P3 1 Version of host bundled with BIND 9 X binutils 2 18 1 cvs2008010 3 7 The GNU assembler linker and binary utilities bridge utils 1 4 5 Utilities for configuring the Linux Ethernet bridge bsdmainutils 6 1 10 collection of more utilities from FreeBSD bsdutils 1 2 13 1 1 1 Basic utilities from 4 4BSD Lite busybox 1 1 10 2 2 Tiny utilities for small and embedded systems ...

Page 7: ... to test the reachability of network hosts klibc utils 1 5 12 2 small utilities built with klibc for early boot libacl1 2 2 47 2 Access control list shared library libapache2 mod php5 5 2 6 dfsg 1 1 lenn y3 server side HTML embedded scripting language Apache 2 module libapr1 1 2 12 5 lenny1 The Apache Portable Runtime Library libaprutil1 1 2 12 dfsg 8 lenn y4 The Apache Portable Runtime Utility Li...

Page 8: ...recision floating point computation libmysqlclient15off 5 0 51a 24 lenny2 MySQL database client library libncurses5 5 7 20081213 1 shared libraries for terminal handling libncursesw5 5 7 20081213 1 shared libraries for terminal handling wide character support libnet lite ftp perl 0 54 2 Perl FTP client with support for TLS libnet ssleay perl 1 35 1 Perl module for Secure Sockets Layer SSL libnet t...

Page 9: ...library libxext6 2 1 0 4 1 X11 miscellaneous extension library libxml2 2 6 32 dfsg 5 GNOME XML library libxmuu1 2 1 0 4 1 X11 miscellaneous micro utility library linux image 2 6 686 2 6 26 17 lenny1 Linux 2 6 image on PPro Celeron P PI P4 linux image 2 6 26 2 686 2 6 26 17lenny1 Linux 2 6 26 image on PPro Celeron P PI P4 linux libc dev 2 6 26 19 Linux support headers for userspace development loca...

Page 10: ... system perl modules 5 10 0 19lenny2 Core Perl modules php5 common 5 2 6 dfsg 1 1 lenn y3 Common files for packages built from the php5 source portmap 6 0 9 RPC port mapper ppp 2 4 4rel 10 1 Point to Point Protocol PPP daemon pppconfig 2 3 18 A text menu based utility for configuring ppp pppoe 3 8 3 PPP over Ethernet driver pppoeconf 1 18 configures PPPoE ADSL connections procps 1 3 2 7 11 proc fi...

Page 11: ...n File preserve user changes to config fil udev 0 125 7 lenny1 dev and hotplug management daemon update inetd 4 31 inetd configuration file updater usbmount 0 0 14 1 automatically mount and unmount USB mass storage devices usbutils 0 73 10 Linux USB utilities util linux 2 13 1 1 1 Miscellaneous system utilities vim 1 7 1 314 3 lenny2 Vi IMproved enhanced vi editor vim common 1 7 1 314 3 lenny2 Vi ...

Page 12: ...configuration will be described in the next chapter Managing Communications The following topics are covered in this chapter Starting from a VGA Console Connecting from a Telnet Console Connecting from an SSH Console Windows Users Linux Users Adjusting the System Time Setting the Time Manually NTP Client Updating the Time Automatically Enabling and Disabling Daemons Setting the Run Level Cron Daem...

Page 13: ...about 30 to 60 seconds for the system to boot up Once the system is ready a login screen will appear on your monitor To log in type the login name and password as requested The default values are both root Login root Password root login as root root 192 168 3 12 s password Last login Mon Jan 22 19 02 16 2007 from 192 168 3 120 For further information check http www moxa com Mount user file system ...

Page 14: ...me subnet as the IP address for the LAN port that you connect to For example if you connect to LAN 1 you could set your PC s IP address to 192 168 3 126 and the netmask to 255 255 255 0 If you connect to LAN 2 you can set your PC s IP address to 192 168 4 126 and the netmask to 255 255 255 0 Use a cross over Ethernet cable to connect your development workstation directly to the target computer or ...

Page 15: ... an SSH console for the DA 710 LX in a Windows environment The following screen shows an example of the configuration that is required Linux Users From a Linux machine use the ssh command to access the DA 710 LX s console utility via SSH ssh 192 168 3 127 Select yes to open the connection root bee_notebook root ssh 192 168 3 127 The authenticity of host 192 168 3 127 192 168 3 127 can t be establi...

Page 16: ...A hwclock Fri Jun 23 23 30 35 2000 0 557748 seconds MOXA date 120910002004 Thu Dec 9 10 00 00 CST 2004 MOXA hwclock w MOXA date hwclock Thu Dec 9 10 01 07 CST 2004 Thu Dec 9 10 01 08 2004 0 933547 seconds MOXA NTP Client The DA 710 LX has a built in NTP Network Time Protocol client that is used to initialize a time request to a remote NTP server Use ntpdate to update the system time ntpdate time s...

Page 17: ... time is 100 seconds Change 100 to a larger number to update RTC less often Save the shell script using any file name For example fixtime How to run the shell script automatically when the kernel boots up Because the root file system is mounted in Read only mode we need to re mount it using writable permission mount o remount rw dev hda1 Copy the example shell script fixtime to directory etc init ...

Page 18: ...root D ixp425_csr 38 root 1256 S stdef 47 root 1368 S usr sbin inetd 53 root 4464 S usr sbin httpd 63 nobody 4480 S usr sbin httpd 64 nobody 4480 S usr sbin httpd 65 nobody 4480 S usr sbin httpd 66 nobody 4480 S usr sbin httpd 67 nobody 4480 S usr sbin httpd 92 bin 1460 S sbin portmap 105 root 1556 S usr sbin rpc statd 109 root 4044 S usr sbin snmpd s l dev null 111 root 2832 S usr sbin snmptrapd ...

Page 19: ...f PID Uid VmSize Stat Command 1 root 1296 S init 2 root S keventd 3 root S ksoftirqd_CPU0 4 root S kswapd 5 root S bdflush 6 root S kupdated 7 root S mtdblockd 8 root S khubd 10 root S jffs2_gcd_mtd3 32 root D ixp425_csr 38 root 1256 S stdef 47 root 1368 S usr sbin inetd 53 root 4464 S usr sbin httpd 63 nobody 4480 S usr sbin httpd 64 nobody 4480 S usr sbin httpd 65 nobody 4480 S usr sbin httpd 66...

Page 20: ... ln s root tcps2 release S60tcps2 MOXA etc rc2 d ls S19nfs common S25nfs user server S99rmnologin S20snmpd S55ssh S99showreadyled S24pcmcia S60tcps2 MOXA etc rc2 d The command SxxRUNFILE has the following meaning S Start the run file while Linux boots up xx A number between 00 99 The smaller number has a higher priority RUNFILE The script file name The command KxxRUNFILE has the following meaning ...

Page 21: ...heduled applications Crontab files have the following format mm h dom mon dow user command minute hour date month week user command 0 59 0 23 1 31 1 12 0 6 0 is Sunday For example if you want to launch a program at 8 00 every day minute hour date month week user command 8 root path to your program The following example demonstrates how to use Cron to update the system time and RTC time every day a...

Page 22: ... type tmpfs rw mode 0755 tmpfs on dev shm type tmpfs rw nosuid nodev devpts on dev pts type devpts rw noexec nosuid gid 5 mode 620 dev hdb2 on home type ext2 rw nfsd on proc fs nfsd type nfsd rw rpc_pipefs on var lib nfs rpc_pipefs type rpc_pipefs rw dev sda1 on media usb0 type vfat rw noexec nodev sync noatime gid 25 dmask 0007 fmask 0117 dev sdb1 on media usb1 type vfat rw noexec nodev sync noat...

Page 23: ...da1 MOXA vi etc fstab etc fstab static file system information file system mount point type options dump pass proc proc proc defaults 0 0 dev hda1 ext2 ro defaults errors remount ro 0 1 dev hdb1 mnt hdb ext2 defaults errors remount ro 0 2 none tmp tmpfs defaults 0 1 dev mtdblock0 home jffs2 defaults 0 2 dev hdc media cdrom0 udf iso9660 user noauto 0 0 dev fd0 media floppy0 auto rw user noauto 0 0 ...

Page 24: ...rg lenny updates main contrib deb src http security debian org lenny updates main contrib deb http volatile debian org debian volatile lenny volatile main deb src http volatile debian org debian volatile lenny volatile main 3 Update the source list after you configure it MOXA apt get update MOXA 4 Once you indicate which package you want to install openswan for example type MOXA apt get install op...

Page 25: ...d on rootfs 772M 397M 335M 55 udev 10M 68K 10M 1 dev dev hda1 772M 397M 335M 55 tmpfs 502M 0 502M 0 lib init rw tmpfs 502M 0 502M 0 dev shm none 502M 19M 483M 4 tmp dev hda2 133M 73M 53M 59 home MOXA ATTENTION You can free up the cache space with the command apt get clean MOXA apt get clean MOXA ...

Page 26: ...Serial Port Operation Mode Telnet FTP Server DNS Client Apache Web Server Default Homepage Disabling the CGI Function Saving Web Pages to a USB Storage Device IPTABLES IPTABLES Hierarchy IPTABLES Modules Observe and Erase Chain Rules Define Policy for Chain Rules Append or Delete Rules NAT Network Address Translation NAT Example Enabling NAT at Bootup PPP Point to Point Protocol Connecting to a PP...

Page 27: ...y with the ifconfig command Changing the interfaces Configuration File 1 Type cd etc network to change directory MOXA cd etc network 2 Type vi interfaces to edit the network configuration file with vi editor You can configure the DA 710 LX s Ethernet ports for static or dynamic DHCP IP addresses MOXA etc network vi interfaces Static IP Address As shown in the example shown below the default static...

Page 28: ... LAN interface when you have inserted one or more LAN or switch modules in your DA 710 s expansion PCI slots In the following example we will insert two DA LN04 RJ LAN modules and one DA SW08 RJ switch module Follow the steps below 1 Make sure the DA 710 computer is powered off 2 Insert the three modules on the rear panel of the DA 710 3 Turn on the DA 710 computer 4 When the system has rebooted u...

Page 29: ...8139too SUBSYSTEM net ACTION add DRIVERS ATTR address 00 90 e8 00 d2 c5 ATTR type 1 KERNEL eth NAME eth12 You may see the configuration for each port See the following descriptions for details LAN port eth0 eth3 the default network configuration for default LAN1 to LAN 4 Switch port eth4 the network configuration for the switch port LAN port eth5 eth8 the network configuration for the LAN ports on...

Page 30: ... Found MOXA CP 118U series board BusNo 7 DevNo 14 6 319161 ACPI PCI Interrupt 0000 07 0e 0 A GSI 17 level low IRQ 17 6 319185 ttyM8 ttyM15 max baud rate 921600 bps 6 319353 mxser_probe 878 5011 4480 6 319355 Found MOXA CP 118U series board BusNo 7 DevNo 15 6 319360 ACPI PCI Interrupt 0000 07 0f 0 A GSI 16 level low IRQ 16 6 319385 ttyM16 ttyM23 max baud rate 921600 bps However please note that the...

Page 31: ...NEL ttyM15 SYMLINK ttyN15 CARD 2 KERNEL ttyM0 SYMLINK ttyN16 KERNEL ttyM1 SYMLINK ttyN17 KERNEL ttyM2 SYMLINK ttyN18 KERNEL ttyM3 SYMLINK ttyN19 KERNEL ttyM4 SYMLINK ttyN20 KERNEL ttyM5 SYMLINK ttyN21 KERNEL ttyM6 SYMLINK ttyN22 Serial Port Operation Mode The serial port expansion module has 8 serial ports named COM1 to COM8 The ports support RS 232 RS 422 4 wire RS 485 and 4 wire RS 485 operation...

Page 32: ...etc vi inetd conf Enabling the Telnet FTP Server The following example shows the default content of the file etc inetd conf The default is to enable the Telnet ftp server 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 Disabling the Telnet FTP Server Disable the daemon by typing in fr...

Page 33: ... d hostname sh start 5 Check the new hostname MOXA hostname etc resolv conf This is the most important file that you need to edit when using DNS For example before you using ntpdate time stdtime gov tw to update the system time you will need to add the DNS server address to the file Ask your network administrator which DNS server address you should use The DNS server s IP address is specified with...

Page 34: ...iles ethers db files rpc db files netgroup nis Apache Web Server Default Homepage The Apache web server s main configuration file is etc apache2 sites available default with the default homepage located at var www apache2 default index html Save your own homepage to the following directory var www apache2 default Save your CGI page to the following directory var www apache2 default cgi bin Before ...

Page 35: ...op your own CGI application make sure your CGI file is executable Saving Web Pages to a USB Storage Device Some applications may have web pages that take up a lot of memory space This section describes how to save web pages to the USB mass storage device and then configure the Apache web server s DocumentRoot to open these pages The files used in this example can be downloaded from Moxa s website ...

Page 36: ...z cgi bin AllowOverride None Options ExecCGI MultiViews SymLinksIfOwnerMatch Order allow deny Allow from all Directory VirtualHost 6 Use the following commands to restart the Apache web server cd etc init d apache2 restart 7 Open your browser and connect to the DA 710 LX by typing the current LAN1 IP address in the browser s address box 8 After finishing modification or writing remember to execute...

Page 37: ...ROUTING chain transfers the destination IP address DNAT POSTROUTING chain works after the routing process and before the Ethernet device process to transfer the source IP address SNAT OUTPUT chain produces local packets Sub tables Source NAT SNAT changes the first source packet IP address Destination NAT DNAT changes the first destination packet IP address MASQUERADE a special form for SNAT If one...

Page 38: ...ios_ns ko ip_conntrack_netlink ko ip_conntrack_pptp ko ip_conntrack_proto_sctp ko ip_conntrack_sip ko ip_conntrack_tftp ko ip_nat_amanda ko ip_nat_ftp ko ip_nat_h323 ko ip_nat_irc ko ip_nat ko ip_nat_pptp ko ip_nat_sip ko ip_nat_snmp_basic ko ip_nat_tftp ko ip_queue ko iptable_filter ko iptable_mangle ko iptable_nat ko iptable_raw ko ip_tables ko ipt_addrtype ko ipt_ah ko ipt_CLUSTERIP ko ipt_dscp...

Page 39: ...org documentation HOWTO packet filtering HOWTO html Since the IPTABLES command is very complex to illustrate the IPTABLES syntax we have divided our discussion of the various rules into three categories Observe and erase chain rules Define policy rules and Append or delete rules Observe and Erase Chain Rules Usage iptables t tables L n t tables Table to manipulate default filter example nat or fil...

Page 40: ...d IP network dport ports j ACCEPT DROP A Append one or more rules to the end of the selected chain I Insert one or more rules in the selected chain as the given rule number i Name of an interface via which a packet is going to be received o Name of an interface via which a packet is going to be sent p The protocol of the rule or of the packet to check s Source address network name host name networ...

Page 41: ... ipt_mac first to load the module ipt_mac NAT Network Address Translation The NAT Network Address Translation protocol translates IP addresses used on one network into IP addresses used on a connecting network One network is designated the inside network and the other is the outside network Typically the DA 710 LX connects several devices on a network and maps local inside network addresses to one...

Page 42: ...is an internal network address Step 1 Insert modules Here 2 dev null means the standard error messages will be dump to null device modprobe ip_tables 2 dev null modprobe ip_nat_ftp 2 dev null modprobe ip_nat_irc 2 dev null modprobe ip_conntrack 2 dev null modprobe ip_conntrack_ftp 2 dev null modprobe ip_conntrack_irc 2 dev null Step 2 Define variables enable routing and erase default rules PATH bi...

Page 43: ...f the PPP server does not prompt for the username and password the command should be entered as follows Replace username with the correct username and replace password with the correct password pppd connect chat v ATDT5551212 CONNECT user username password password dev ttyM0 115200 crtscts modem The pppd options are described below connect chat etc This option gives the command to contact the PPP ...

Page 44: ... Depending on your distribution the command might be located elsewhere After executing the command you should be able to see all of the network interfaces that are UP ppp0 should be one of them and you should recognize the first IP address as your own and the P t P address point to point address the address of your server The output is similar to the following lo Link encap Local Loopback inet add...

Page 45: ...mmands This first example applies to using a modem and requiring authorization with a username and password pppd dev ttyM0 115200 crtscts modem 192 168 16 1 192 168 16 2 login auth You should also add the following line to the file etc ppp pap secrets The first star lets everyone login The second star lets every host connect The pair of double quotation marks indicates that the file etc passwd can...

Page 46: ...pawn pppd call dialin etc inittab MOXA umount PPPoE The following procedure is for setting up PPPoE 1 Connect the DA 710 LX s LAN port to an ADSL modem with a cross over cable HUB or switch 2 Log in to the DA 710 LX as the root user 3 Edit the file etc ppp chap secrets and add the following username hinet net password Secrets for authentication using CHAP client server secret IP addresses PPPOE ex...

Page 47: ... password for the account 5 Edit the file etc ppp options and add the following line plugin rp pppoe received Note it is not advisable to use this option with the persist option without the demand option If the active filter option is given data packets which are rejected by the specified activity filter also count as the link being idle idle n Specifies how many seconds to wait before re initiati...

Page 48: ... 168 95 1 1 nameserver 139 175 10 20 MOXA etc cat resolv conf resolv conf This file is the resolver configuration file See resolver 5 nameserver 192 168 1 16 nameserver 168 95 1 1 nameserver 139 175 10 20 nameserver 140 115 1 31 nameserver 140 115 236 10 MOXA etc 8 Use the following command to create a pppoe connection pppd eth0 The ADSL modem is connected to the LAN1 port which is named eth0 If t...

Page 49: ...e IP address of the NFS server SNMP Simple Network Management Protocol The DA 710 LX comes with the SNMP V1 Simple Network Management Protocol agent software pre installed It supports RFC1317 RS 232 like group and RFC 1213 MIB II The following shows example shows an SNMP agent responding to a query from the SNMP browser on the host site SNMP QUERY STARTED root jaredRH90 root snmpwalk v 1 c public ...

Page 50: ...leAuthenTraps 0 INTEGER disabled 2 SNMPv2 MIB snmpSilentDrops 0 Counter32 0 SNMPv2 MIB snmpProxyDrops 0 Counter32 0 root jaredRH90 root SNMP QUERY FINISHED ATTENTION Click on the following links for more information about RFC1317 RS 232 like group and RFC 1213 MIB II http www faqs org rfcs rfc1317 html http www ietf org rfc rfc1213 txt OpenVPN OpenVPN provides two types of tunnels for users to imp...

Page 51: ...e command openvpn genkey secret secrouter key 3 Copy the file that is generated to the OpenVPN machine scp etc openvpn secrouter key 192 168 8 174 etc openvpn ATTENTION A preshared key is located at etc openvpn secrouter key You can use it for testing purposes We suggest creating a new key for non testing purpose 4 On machine OpenVPN A modify the remote address in the configuration file etc openvp...

Page 52: ...uration file etc openvpn tap0 br conf point to the peer remote 192 168 8 173 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 tap0 br sh comp lzo 7 Next modify the routing table in etc openvpn tap0 br sh script file Start bin sh value after net is the subnet behind the remote peer route add net 192 168 2 0 netmask 255 255 2...

Page 53: ...2 168 4 0 0 0 0 0 255 255 255 0 U 0 0 0 br0 192 168 3 0 0 0 0 0 255 255 255 0 U 0 0 0 eth0 192 168 30 0 0 0 0 0 255 255 255 0 U 0 0 0 eth3 192 168 8 0 0 0 0 0 255 255 255 0 U 0 0 0 br0 Interface eth1 and device tap0 both connect to the bridging interface and the virtual device tun sits on top of tap0 This ensures that all traffic coming to this bridge from internal networks connected to interface ...

Page 54: ... previous example The only difference is that you will need to comment out the parameter up in etc openvpn tap0 br conf of OpenVPN A and etc openvpn tap0 br conf of OpenVPN B point to the peer remote 192 168 8 174 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 tap0 br sh comp lzo Routed IP 1 Set up four machines as shown ...

Page 55: ...er DES EDE3 CBC auth MD5 tun mtu 1500 tun mtu extra 64 ping 40 ifconfig 192 168 4 174 192 168 2 173 up etc openvpn tun sh And then modify the routing table in script file etc openvpn tun sh Start bin sh value after net is the subnet behind the remote peer route add net 192 168 2 0 netmask 255 255 255 0 gw 5 end The first argument of parameter ifconfig is the local internal interface and the second...

Page 56: ...4 4 Programmer s Guide The following topics are covered in this chapter Device API RTC Real Time Clock UART Digital I O Programmable LEDs ...

Page 57: ... 4 wire RS485 depending on the expansion module models Our system will generate tty device node as dev ttyM0 dev ttyMn For example if you have installed the 8 port DA SP08 I DB serial module the device node will be dev ttyM0 to dev ttyM7 To configure the serial ports follow these steps 1 You must include moxadevice h which you can find in the folder example moxalib in CD define RS232_MODE 0 define...

Page 58: ...include moxadevice h include termios h struct termios term int fd speed fd open dev ttyM0 O_RDWR tcgetattr fd term if term c_cflag CBAUD CBAUDEX B4000000 follow the standard termios baud rate define else ioctl fd MOXA_GET_SPECIAL_BAUD_RATE speed Baudrate inaccuracy Divisor 921600 Target Baud Rate Only Integer part ENUM 8 921600 Target Divisor Round up or down Inaccuracy Target Baud Rate 921600 Div...

Page 59: ... fail define DIO_ERROR_DURATION 4 The value of duration is not 0 or not in the range 40 duration 3600000 milliseconds 1 hour define DIO_ERROR_DURATION_20MS 5 The value of duration must be a multiple of 20 ms define DIO_OK 0 DIN and DOUT definitions define DIO_HIGH 1 define DIO_LOW 0 Moxa functions for DI DO Function int set_dout_state int doport int state Description Set the DOUT port to high or l...

Page 60: ...ample if the DIN duration is 200 ms this event will be generated when the DIN pin stays in the same state for a time between 176 ms and 200 ms Output None Return Refer to the error code Function int get_din_event int diport int mode long int duration Description To retrieve the DIN event configuration including mode DIN_EVENT_HIGH_TO_LOW or DIN_EVENT_LOW_TO_HIGH and the value of duration Input dip...

Page 61: ...e h endif include fcntl h Due to hardware limitation MIN_DURATION should be 60 for DA710 define MIN_DURATION 40 static char DataString 2 Low High static void hightolowevent int diport printf nDIN port d high to low n diport static void lowtohighevent int diport printf nDIN port d low to high n diport int main int argc char argv int i j state retval unsigned long duration while 1 printf nSelect a n...

Page 62: ...PORT j get_din_state j state printf s DataString state printf n printf DOUT data for j 0 j MAX_DOUT_PORT j get_dout_state j state printf s DataString state printf n else if i 3 set low to high event printf Please keyin the DIN number scanf d i printf Please input the DIN duration this minimun value must be over d MIN_DURATION scanf lu duration retval set_din_event i lowtohighevent DIN_EVENT_LOW_TO...

Page 63: ...j 0 j MAX_DOUT_PORT j retval get_din_event j i duration switch i case DIN_EVENT_HIGH_TO_LOW printf htl lu duration break case DIN_EVENT_LOW_TO_HIGH printf lth lu duration break case DIN_EVENT_CLEAR printf clr lu duration break default printf err break printf n else printf Select error please select again n switch retval case DIO_ERROR_PORT printf DIO error port n break case DIO_ERROR_MODE printf D...

Page 64: ... multiple of 20 ms n break return 0 DIO Program Make File Example include compile mk CC PREFIX gcc STRIP PREFIX strip AR PREFIX ar LNAME moxalib all release release MOXALIB_OBJ AR rcs lib LNAME a MOXALIB_OBJ o c CC c install lib LNAME a cp a lib LNAME a MOXALIB_INSTALL_DIR cp a moxadevice h usr local arm linux include cp a moxadevice h usr local arm linux arm linux include clean bin rm f o a ...

Page 65: ... ko module has not been loaded use the modprobe command to load it and then use the lsmod command once again to verify the module has correctly loaded as below MOXA modprobe moxa_pled MOXA lsmod grep moxa_pled moxa_pled 2464 0 2 The 8 LEDs each are each mapped in a one to one correspondence to an 8 bit argument with the leftmost LED corresponding to the leftmost first bit and the rightmost bit cor...

Page 66: ...mpactFlash card shipped with the DA 710 LX computer Although it rarely happens you may find on occasion that operating system files and or the disk file system are damaged This chapter describes how to recover the Linux operating system The following topics are covered in this chapter Recovery Environment Recovery Procedure ...

Page 67: ...least a 256 MB capacity b Format your USB disk with the HP USB Disk Format Tool Open the utility and select the device and FAT file system You need empty disk only DO NOT check the option Create a DOS startup disk c Click Start ATTENTION The HP USB Disk Storage Format Tool can be downloaded from many web sites Do a search on HP USB Disk Storage Format Tool from any search engine to locate the tool...

Page 68: ...D shipped with the DA 710 LX computer b Configure Windows Explorer to show hidden files including protected operating system files c Copy all files in the firmware directory to the root directory of your USB disk d Open a DOS prompt and type M syslinux exe M to create a bootable Linux disk In this example M is the USB Disk drive number ...

Page 69: ...Advanced Hard Disk Boot Priority and then press Enter d From the setup menu use or to select the USB device e Press to move the selection up to the first priority and press Esc to exit the setup menu f Make sure the first boot device is Hard Disk If not press Enter to change it g Select Exit Save Exit Setup and then press Enter h Choose Y to save to the CMOS and then exit ...

Page 70: ...image of your hard disk and to restore your hard disk from such an image Please be aware that if you choose to restore your hard disk All the data contained on this computer might be lost during the restoration You man choose to abort now by stopping the computer now OK b Choose OK to go to the next step c Choose shut down the DA 710 LX when the restoration is finished PING Partition Image Is Not ...

Page 71: ...to backup Note that you cannot restore a partition to itself So every partition but one the destination can be checked Use SPACE to SELECT an entry Choose THIS if you want a restoration hda1 Linux lost found home etc media cdrom usr hda2 Linux sda1 OK Cancel f Choose the restoration source device sda1 Choose the partition where to store the back where to the backup is stored hda1 Linux lost found ...

Page 72: ...if you want a ghost like images of your partitions Choose Backup_Local_Hard_Driver if prefer a zip archive DA710_V1 0_Build_09112420 Create_New_Image Backup_Local_Hard_Driver OK Cancel i Choose Yes to start the restoration After the restoration is finished the system will halt and you will need to reboot to restart the restored system BIOS setting has been recorded on your image Do you want them t...

Page 73: ...elect Advanced Hard Disk Boot Priority and then press Enter c From the setup menu use or to select the DOM or CompactFlash device d Press to move the selection up to the first priority and press Esc to exit the setup menu e Select Exit Save Exit Setup and then press Enter f Choose Y to save to the CMOS and then exit g Wait a few minutes for the system to boot When the recovery process is finished ...

Reviews: