Home
IA240/241 Linux User`s Manual
Contents
1. Baudrate 115200 bps Parity None Data bits 8 Stop bits 1 Flow Control None Terminal VT100 Once the connection is established the following window will open 2 2 1A240 241 Linux User s Manual Getting Started E s PComm Terminal Emulator COM1 115200 None 8 1 T100 EEK Profile Edit PortManager Window Help 2 aa elles Size E COM1 115200 None 8 1 T100 428 S sbin getty 115200 ttySl 628 R ps orr root Moxa ers Moxa login root Password EERE E22 23 EEEE EE EEEE EE E ME E EEE Ed E23 ger EERS 88 88 EERS EERS EER sgg 22 EEE 2 Ees g 82 sgg E22 25 8 8 8 sgg EER g Ef 2 2 ges 88 22 gg gg Ei ze 23 g 8 2 2 E23 S888 EE ER HEE FF FF FF E23 EERE g HEE s EE g FF FE 8 sgg EEEE 2 22 3 El 88 FF HER ges E22 22 8 2 ggg s HEE sgg gg 88 sgg 8 88 8 E23 8 88 8 8 gg 88 8 E23 EER 8 EEEESS F BERERE EEEE EEE 22 HEERE KKKFSSSSSKH FEFEFE For further information check http www moxa comf root Moxa State OPEN IR BRR To log in type the Login name and password as requested The default values are both root Login root Password root Telnet Console If you know at least one of the two IP addresses and netmasks then you can use Telnet to connect to the A240 241 s console utility The default IP address and Netmask for each of the two ports are given below Default IP Address Netmask LAN 1 192 168 3 127 255 255 255 0 LAN
2. ar Manages archives static libraries as Assembler C g C compiler cpp C preprocessor gcc C compiler gdb Debugger Id Linker nm Lists symbols from object files objcopy Copies and translates object files objdump Displays information about object files ranlib Generates indexes to archives static libraries readelf Displays information about ELF files 5 2 1A240 241 Linux User s Manual Development Tool Chains size Lists object file section sizes strings Prints strings of printable characters from files usually object files strip Removes symbols and sections from object files usually debugging information On Line Debugging with GDB The tool chain also provides an on line debugging mechanism to help you develop your program Before performing a debugging session add the option ggdb to compile the program A debugging session runs on a client server architecture on which the server gdbserver is installed int the targe computer and the client ddd is installed in the host computer We ll asuumne that you have uploaded a program named hello debug to the target computer and strat to debug the program 1 Log on to the target computer and run the debugging server program gdbserver 192 168 4 142 2000 hello debug Process hello debug created pid 38 The debugging server listens for connections at network port 2000 from the network interface 192 168 4 142 The name of the prog
3. Input int d open device node return file handle int request argument in or out Use the desktop Linux s man page for detailed documentation man ioctl RTC Real Time Clock Buzzer The device node is located at dev rtc The IA240 241 supports Linux standard simple RTC control You must include lt linux rtc h gt 1 Function RTC_RD_TIME int ioctl fd RTC RD TIME struct rtc time time Description read time information from RTC It will return the value on argument 3 2 Function RTC_SET_TIME int ioctl fd RTC_SET_TIME struct rtc_time time Description set RTC time Argument 3 will be passed to RTC The device node is located at dev console The A240 241 supports Linux standard buzzer control with The IA240 241 s buzzer running at a fixed frequency of 100 Hz You must include lt sys kd h gt 6 2 1A240 241 Linux User s Manual Programmer s Guide Function KDMKTONE ioctl fd KDMKTONE unsigned int arg Description The buzzer s behavior is determined by the argument arg The high word part of arg gives the length of time the buzzer will sound and the low word part gives the frequency The buzzer s on off behavior is controlled by software If you call the ioctl function you MUST set the frequency at 100 Hz If you use a different frequency the system could crash WDT Watch Dog Timer 1 Introduction The WDT works like a watch dog function You
4. ATDT5551212 CONNECT user username password password dev ttyMO 115200 crtscts modem The pppd options are described below connect chat etc This option gives the command to contact the PPP server The chat program is used to dial a remote computer The entire command is enclosed in single quotes because pppd expects a one word argument for the connect option The options for chat are given below y verbose mode log what we do to syslog Double quotes don t wait for a prompt but instead do note that you must include a space after the second quotation mark ATDT5551212 Dial the modem and then CONNECT Wait for an answer wow Send a return null text followed by the usual return ogin username word password Log in with username and password Refer to the chat man page chat 8 for more information about the chat utility dev Specify the callout serial port 115200 The baudrate debug Log status in syslog ertscts Use hardware flow control between computer and modem at 115200 this is a must modem Indicates that this is a modem device pppd will hang up the phone before and after making the call defaultroute Once the PPP link is established make it the default route if you have a PPP link to the Internet this is probably what you want 4 14 1A240 241 Linux User s Manual Managing Communication 192 1 1 17 This is a degenerate case of a
5. Flash Memory Map NOTE Device Partition sizes are hard coded into the kernel binary To change the partition sizes you will need to rebuild the kernel The flash memory map is shown in the following table Address Size Contents 0x00000000 0x0003FFFF 256 KB Boot Loader Read ONLY 0x00040000 0x00 IFFFFF 1 8 MB Kernel object code Read ONLY 0x00200000 0xOO9FFFFF 8 MB Root file system JFFS2 Read ONLY 0x00A 00000 OxOOFFFFFF 6 MB User directory JFFS2 Read Write Mount the user file system to mnt usrdisk with the root file system Check to see if the user file system was mounted correctly If user file system is okay the kernel will change the root file system to mnt usrdisk If the user file system is not okay the kernel will use the default Moxa file system To finish boot process run the init program 1 The default Moxa file system only enables the network and CF It lets users recover the user file system when it fails 2 The user file system is a complete file system Users can create and delete directories and files including source code and executable files as needed 3 Users can create the user file system on the PC host or target platform and then copy it to the IA240 241 API The IA240 241 supports control devices with the ioctl system API You will need to include lt moxadevice h gt and use the following ioctl function int ioctl int d int request
6. This wait period only applies if the connect or pty option is used plugin pppoe so lt End of File gt options line 1 of 342 4 17 1A240 241 Linux User s Manual Managing Communication 6 Add one of two files etc ppp options eth0 or etc ppp options eth1 The choice depends on which LAN is connected to the ADSL modem If you use LANI to connect to the ADSL modem then add ete ppp options eth0 If you use LAN to connect to the ADSL modem then add etc ppp options eth1 The file context is shown below name username hinet net 4 5 1 02 mru 1492 defaultroute noipdefault options ixp0 line 1 of 5 20 Type your username the one you set in the etc ppp pap secrets and etc ppp chap secrets files after the name option You may add other options as desired 7 Setup DNS If you are using DNS servers supplied by your ISP edit the file etc resolv conf by adding the following lines of code nameserver ip_addr_of_first_dns_server nameserver ip_addr_of_second_dns_server For example nameserver 168 95 1 1 nameserver 139 175 10 20 8 Use the following command to create a pppoe connection pppd eth0 The eth0 is what is connected to the ADSL modem LAN port The example above uses LAN To use LAN2 type pppd eth1 9 Type ifconfig ppp0 to check if the connection is OK or has failed If the connection is OK you will see information about the ppp0 setting for the IP address Use
7. 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 ifOutErrors 3 counter 0 ifOutErrors 4 counter 0 ifOutErrors 5 counter 0 ifOutErrors 6 counter 0 ifOutQLen 1 gauge 1000 ifOutQLen 2 gauge 1000 ifOutQLen 3 gauge 0 ifOutQLen 4 gauge 0 ifOutQLen 5 gauge 0 ifOutQLen 6 gauge 0 ifSpecific 1 object identifier null oid zeroDotZero ifSpecific 2 object identifier null oid zeroDotZero ifSpecific 3 object identifier null oid zeroDotZero ifSpecific 4 object identifier null oid zeroDotZero ifSpecific 5 object identifier null oid zeroDotZero ifSpecific 6 object identifier null oid zeroDotZero atIfIndex 1 192 168 27 139 integer 1 atlfIndex 2 192 168 4 127 integer 2 atPhysAddress 1 192 168 27 139 octet string 00 90 E8 10 02 41 hex atPhysAddress 2 192 168 4 127 octet string 00 90 E8 10 02 40 hex atNetAddress 1 192 168 27 139 ipaddress 192 168 27 139 atNetAddress 2 192 168 4 127 ipaddress 192 168 4 127 ipForwarding 0 integer forwarding 1 ipDefaultTTL O integer 64 ipInReceives 0 counter 1289 ipInHdrErrors 0 counter 0 ipInAddrErrors 0 counter 0 ipForwDatagrams 0 counter 9 ipInUnknownProtos 0 counter 0 ipInDiscards 0 counter 0 ipInDelivers 0 counter 1160 ipOutRequests 0 counter 858 ipOutDiscards 0 counter 0 ipOutNoRoutes 0 counter 0 ipReasmTimeout 0 integer 0 ipReasmReqds 0 counter 0 ipReasmOKs 0 co
8. 192 168 2 127 PUTTY root Moxa date Wied ann 23 ZO CST ZOOO root Moxa hwclock Fri Jun 23 23 30 35 2000 0 557748 seconds root Moxa date 120910002004 mau Dec A 00000 CST 200a root Moxa hwclock w root Moxa date hwclock mau Dec Ch LOON ET CSi 200 Thu Dec 9 10 01 08 2004 0 933547 seconds root Moxa NTP Client The IA240 241 has a built in NTP Network Time Protocol client that is used to initialize a time request to a remote NTP server Use ntpdate lt this client utility gt to update the system time ntpdate time stdtime gov tw hwclock w Visit http www ntp org for more information about NTP and NTP server addresses 10 0 53 100 PuTTY mmm root Moxa date hwclock Sat Jan 1 00 00 36 CST 2000 Sat Jan 1 00 00 37 2000 0 772941 seconds root Moxa ntpdate time stdtion gov tw 9 Dec 10 58 53 ntpdate 207 step time server 220 130 158 52 offset 155905087 9 84256 sec root Moxa hwclock w root Moxa date hwclock apes Dee CV AOS Er 2004 Thu Dec 9 10 59 12 2004 0 844076 seconds root Moxa NOTE Before using the NTP client utility check your IP and DNS settings to make sure that an Internet connection is available Refer to Chapter 2 for instructions on how to configure the Ethernet interface and see Chapter 4 for DNS setting information Updating the Time Automatically In this subsection we show how to use a shell script to update the time automatically E
9. E Nool chain windows Browse lt Back Cancel It may take anywhere from 5 to 20 minutes to check the packages in the CD ROM 4 All packages are selected by default Choose Next to continue 2 Moxa Linux Tool Chain Setup Select Packages Select Packages Select packages to install Bi View Category Category Cur New Bi Sr Package All amp Default Admin Default Archive 4 Default Base amp Default Database 4 Default Devel 4 Default Doc amp Default Editors 4 Default Games 4 Default Graphics s Default Cancel 5 6 1A240 241 Linux User s Manual Development Tool Chains e Category column Shows a hierarchical display of packages with category name highest and package name lowest Click the plus sign next to a category name to open the category and see the packages within that category e Base Category List all packages that will be installed by default along with any dependencies If you view the Base column for the Base category you should see every package selected for installation e Packages In the packages listing field package names are arranged by Category Full Partial according to the View by button When viewing by Category click the plus sign to open or close the packages under that category This is the same list you see in flat form when viewing by Full Partial By default named packages are installed e Install If the pack
10. ifInErrors 4 counter 0 ifInErrors 5 counter 0 ifInErrors 6 counter 0 ifInUnknownProtos 1 counter 0 ifInUnknownProtos 2 counter 0 ifInUnknownProtos 3 counter 0 ifInUnknownProtos 4 counter 0 ifInUnknownProtos 5 counter 0 ifInUnknownProtos 6 counter 0 ifOutOctets 1 counter 51987 ifOutOctets 2 counter 3832 ifOutOctets 3 counter 0 ifOutOctets 4 counter 0 ifOutOctets 5 counter 0 ifOutOctets 6 counter 0 ifOutUcastPkts 1 counter 506 ifOutUcastPkts 2 counter 42 ifOutUcastPkts 3 counter 0 ifOutUcastPkts 4 counter 0 ifOutUcastPkts 5 counter 0 ifOutUcastPkts 6 counter 0 ifOutNUcastPkts 1 counter 0 ifOutNUcastPkts 2 counter 0 ifOutNUcastPkts 3 counter 0 ifOutNUcastPkts 4 counter 0 ifOutNUcastPkts 5 counter 0 ifOutNUcastPkts 6 counter 0 ifOutDiscards 1 counter 0 ifOutDiscards 2 counter 0 ifOutDiscards 3 counter 0 ifOutDiscards 4 counter 0 ifOutDiscards 5 counter 0 ifOutDiscards 6 counter 0 ifOutErrors 1 counter 0 ifOutErrors 2 counter 0 4 21 1A240 241 Linux User s Manual Managing Communication 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
11. ifIndex 2 integer 2 ifIndex 3 integer 3 ifIndex 4 integer 4 ifIndex 5 integer 5 ifIndex 6 integer 6 ifDescr 1 octet string eth0 ifDescr 2 octet string eth ifDescr 3 octet string Serial port 0 ifDescr 4 octet string Serial port 1 ifDescr 5 octet string Serial port 2 ifDescr 6 octet string Serial port 3 ifType 1 integer ethernet csmacd 6 ifType 2 integer ethernet csmacd 6 ifType 3 integer other 1 ifType 4 integer other 1 ifType 5 integer other 1 ifType 6 integer other 1 ifMtu l integer 1500 ifMtu 2 integer 1500 ifMtu 3 integer 0 ifMtu 4 integer 0 ifMtu 5 integer 0 ifMtu 6 integer 0 ifSpeed 1 gauge 100000000 ifSpeed 2 gauge 100000000 ifSpeed 3 gauge 38400 ifSpeed 4 gauge 38400 ifSpeed 5 gauge 38400 ifSpeed 6 gauge 38400 ifPhysAddress 1 octet string 00 90 E8 10 02 41 hex ifPhysAddress 2 octet string 00 90 E8 10 02 40 hex ifPhysAddress 3 octet string 00 hex ifPhysAddress 4 octet string 00 hex ifPhysAddress 5 octet string 00 hex ifPhysAddress 6 octet string 00 hex ifAdminStatus 1 integer up 1 ifAdminStatus 2 integer up 1 ifAdminStatus 3 integer down 2 ifAdminStatus 4 integer down 2 ifAdminStatus 5 integer down 2 ifAdminStatus 6 integer down 2 ifOperStatus 1 integer up 1 ifOperStatus 2 integer up 1 ifOperS
12. s Manual UC Finder 3 Click on Next to install program files in the default directory or select an alternative location 18 Setup UC Finder Ready to Install Setup is now ready to begin installing UC Finder on your computer Click Install to continue with the installation or click Back if you want to review or change any settings Additional tasks Create a desktop icon Completing the UC Finder Setup Wizard Setup has finished installing UC Finder on your computer The application may be launched by selecting the installed icons Click Finish to exit Setup 8 3 1A240 241 Linux User s Manual Broadcast Search The Broadcast Search function is used to locate all IA240 241 units that are connected to the same LAN as your Windows computer Since the Broadcast Search function searches by MAC address and not IP address all A240 241 s connected to the LAN will be found regardless of whether or not they are on the same subnet as the host 1 2 The Searching window displays the Model MAC Address and IP Address of devices that Click o n the Broadcast Search button to start searching F UC Finder Eile Function About Broadcast Search No Mode MAC Address IP Address Search Result 0 UC were located Searching Searching for UC Found 1 UC s remain timeout 3 second s No Model MAC Address IP Address 00 90 E
13. the file handle from swtd_open return value Output OK will be zero The other has some error to get error code from errno 4 Special Note When you kill the application with 9 or kill without option or Ctrl c the kernel will change to auto ack the sWatchDog When your application enables the sWatchDog and does not ack your application may have a logical error or your application has made a core dump The kernel will not change to auto ack This can cause a serious problem causing your system to reboot again and again 5 User application example Example 1 include lt stdio h gt include lt stdlib h gt include lt string h gt include lt moxadevice h gt int main int argc char argv int fd fd swtd_open if fd lt 0 printf Open sWatchDog device fail n exit 1 swtd_enable fd 5000 enable it and set it 5 seconds while 1 do user application want to do swtd_ack fd swtd_close fd exit 0 The makefile is shown below all arm linux gcc O xxxx xxxx c lmoxalib Example 2 include lt stdio h gt include lt stdlib h gt include lt signal h gt include lt string h gt include lt sys stat h gt include lt sys ioctl h gt include lt sys select h gt include lt sys time h gt include lt moxadevice h gt 6 5 1A240 241 Linux User s Manual Programmer s Guide static void mydelay unsigned long
14. 1 6 integer ded 6 rs232InSigName 2 6 integer ded 6 rs232InSigName 3 6 integer ded 6 rs232InSigName 4 6 integer ded 6 rs232InSigState 1 2 integer off 3 rs232InSigState 2 2 integer off 3 rs232InSigState 3 2 integer off 3 rs232InSigState 4 2 integer off 3 4 26 1A240 241 Linux User s Manual Managing Communication 460 rs232InSigState 1 3 integer off 3 461 rs232InSigState 2 3 integer off 3 462 rs232InSigState 3 3 integer off 3 463 rs232InSigState 4 3 integer off 3 464 rs232InSigState 1 6 integer off 3 465 rs232InSigState 2 6 integer off 3 466 rs232InSigState 3 6 integer off 3 467 rs232InSigState 4 6 integer off 3 468 rs232OutSigPortIndex 1 1 integer 1 1 469 rs232OutSigPortIndex 2 1 integer 2 2 470 rs232OutSigPortIndex 3 1 integer 3 3 471 rs232OutSigPortIndex 4 1 integer 4 4 472 rs232OutSigPortIndex 1 4 integer 1 1 473 rs232OutSigPortIndex 2 4 integer 2 2 474 rs232OutSigPortIndex 3 4 integer 3 3 475 rs232OutSigPortIndex 4 4 integer 4 4 476 rs232OutSigName 1 1 integer rts 1 477 rs232OutSigName 2 1 integer rts 1 478 rs2320utSigName 3 1 integer rts 1 479 rs232OutSigName 4 1 integer rts 1 480 rs232OutSigName 1 4 integer dtr 4 481 rs2320utSigName 2 4 integer dtr 4 482 rs2320utSigName 3 4 integer dtr 4 483 rs232OutSigName 4 4 integer dtr 4 484 rs232O0utSigState 1 1 integer of f 3
15. 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 ipRouteProto 192 168 4 0 integer local 2 ipRouteProto 192 168 27 0 integer local 2 ipRouteAge 192 168 4 0 integer 0 ipRouteA ge 192 168 27 0 integer 0 ipRouteMask 192 168 4 0 ipaddress 255 255 255 0 ipRouteMask 192 168 27 0 ipaddress 255 255 255 0 ipRouteMetric5 192 168 4 0 integer 1 ipRouteMetric5 192 168 27 0 integer 1 ipRouteInfo 192 168 4 0 object identifier null oid zeroDotZero ipRouteInfo 192 168 27 0 object identifier null oid zeroDotZero ipNetToMedialfIndex 1 192 168 27 139 integer 1 ipNetToMedialfIndex 2 192 168 4 127 integer 2 ipNetToMediaPhysAddress 1 192 168 27 139 octet string 00 90 E8 10 02 41 hex ipNetToMediaPhysAddress 2 192 168 4 127 octet string 00 90 E8 10 02 40 hex ipNetToMediaNetAddress 1 192 168 27 139 ipaddress 192 168 27 139 ipNetToMediaNetAddress 2 192 168 4 127 ipaddress 192 168 4 127 ipNetToMediaType 1 192 168 27 139 integer static 4 ipNetToMediaType 2 192 168 4 127 integer static 4 ipRoutingDiscards 0 integer 0 icmpInMsgs 0 counter 130 icmpInErrors 0 counter 3 icmpInDestUnreachs 0 counter 128 icmpInTimeExcds 0 counter 0 icmpInParmProbs 0
16. bash command shell Configuration instructions are given in the next section ATTENTION Serial Console Reminder Remember to choose VT100 as the terminal type Use the cable CBL RJ45F9 150 which comes with the IA240 241 to connect to the serial console port Telnet Reminder When connecting to the IA240 241 over a LAN you must configure your PC s Ethernet IP address to be on the same subnet as the IA240 241 that you wish to contact If you do not get connected on the first try re check the serial and IP settings and then unplug and re plug the IA240 241 s power cord SSH Console The IA240 241 supports an SSH Console to provide users with better security options Windows Users Click on the link http www chiark greenend org uk sgtatham putty download html to download PuTTY free software to set up an SSH console for the A240 241 in a Windows environment The following figure shows a simple example of the configuration that is required 1A240 241 Linux User s Manual Getting Started ox PuTTY Configuration Se Session A Logging 7 3 Terminal Keyboard Bell Features Window Appearance Behaviour Translation Selection Colours Connection Data Proxy Telnet Rlogin SSH Kex Auth x11 Tunnels Linux Users Basic options for your PuTTY session Specify your connection by host name or IP address Host Name or IP address Port 1192 168 27 122 22 Protocol O Raw Rlogin Loa
17. s Manual Programmer s Guide Baudrate inaccuracy Divisor 921600 Target Baud Rate Only Integer part ENUM 8 921600 Targer Divisor Round up or down Inaccuracy Target Baud Rate 921600 Divisor ENUM 8 100 E g To calculate 500000 bps Divisor 1 ENUM 7 Inaccuracy 1 7 The Inaccuracy should less than 2 for work reliably Special Note DI DO 1 Ifthe target baudrate is not a special baudrate e g 50 75 110 134 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400 460800 921600 the termios cflag will be set to the same flag 2 If you use stty to get the serial information you will get speed equal to 0 int set_dout_state int doport int state Description Set the digital output state to high or low Input int doport the digital output port number It is 0 to 3 int state the output state high or low You can use define DIO_HIGH or DIO_LOW Output OK will be zero int get_din_state int doport int state Description Get the digital input current state at now Input int diport the digital input port number It is 0 to 3 int state To save the digital input state at now Output OK will be zero int get_dout_state int doport int state Description Get the digital output current state at now Input int doport the digital output port number It is 0 to 3 int state To save the digital output state at now O
18. 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 1025 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 2049 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 2049 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 1026 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 1026 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 9 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 9 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 111 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 111 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 80 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 80 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 21 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 21 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 22 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 22 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 23 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 23 0 0 0 0 0 ipaddress 192 168 4 127 tcpConnLocalPort 192 168 27 139 1024 0 0 0 0 0 integer 1024 tepConnLocalPort 192 168 4 127 1024 0 0 0 0 0 integer 1024 tepConnLocalPort 192 168 27 139 1025 0 0 0 0 0 intege
19. 1000 1000 value it_interval value it_value setitimer ITIMER_REAL amp value NULL r Test for dout kept in the same frequency but din set for different duration for i 0 i lt DURATION_NUM i if duration 1 i lt duration 1 nDuration reset these counters ndin_StateChangeDetected 0 ndout_StateChangeDetected 0 printf DI duration d DO duration d n duration 1 i duration 1 nDuration set_din_event 0 low2highevent DIN EVENT LOW TO HIGH duration 1 i while ndout StateChangeDetected lt TEST NUM 6 13 1A240 241 Linux User s Manual Programmer s Guide pause printf ndin StateChangeDetected d ndout_StateChangeDetected d n ndin StateChangeDetected ndout StateChangeDetected printf loss detection probability f n ndout StateChangeDetected ndin StateChangeDetected 100 0 nd out _StateChangeDetected end of for i 0 i lt DURATION NUM i while 1 pthread_exit NULL void init_sigaction void struct sigaction act act sa_handler dout_control act sa_flags 0 sigemptyset amp act sa_mask sigaction SIGALRM amp act NULL int main int argc char argv pthread_t dio_test init_sigaction set_dout_state 0 0 set the DOUTO as high set_din_event 0 low2highevent DIN_EVENT_LOW_TO_HIGH duration 1 0 dio_test_function while nDuration lt DURATION_NUM u
20. 12 insight ico drwxrwx 5 Jared Wu 4294967295 O Nov 4 dale alto Tib rwxr x 1 Jared_Wu 4294967295 53 Nov 4A 10712 mox D t 1 Jared_Wu 4294967295 3262 Nov 4 11 12 moxa ico 4 Jared_Wu 4294967295 0 Nov 4 18 11 tmp 3 Jared_Wu 4294967295 0 Nov 4 11 06 usr 6 Jared_Wu 4294967295 0 Nov 4 II706 yar LWxr xX drwxrwx drwxrwx 1 drwxrwx cd hello make usr local mxscaleb bin mxscaleb gcc o hello release hello c usr local mxscaleb bin mxscaleb strip s hello release usr local mxscaleb bin mxscaleb gcc ggdb o hello debug hello c ls Makefile README hello debug hello release hello c After that use FTP to upload the executable file to the UC and then run the executable ftp gt bye SED a Ial S Connected to 192 168 14 9 220 Moxa FTP server lt Version wu 2 6 1 lt 2 gt Mon Nov 24 12 17 04 CST 2003 gt ready User lt 192 168 14 9 lt none gt gt root 331 Password required for root Password 230 User root logged in Eep bin 200 PORT command successful 150 Opening BINARY mode data connection for hello release 226 Transfer complete ftp 2744 bytes sent in 0 00Seconds 2744000 00Kbytes sec ftp gt bye 221 You have transferred 2744 bytes in 1 files 221 Total traffie for this session was 3131 bytes in I Transfers 221 Thank you for using the FTP service on Moxa 221 Goodbye root Moxa chmod 777 hello release root Moxa hello release Hello 5 10 1A240 241 Linux User
21. 226 Transfer complete 4996 bytes sent in 0 00013 seconds 3 9e 04 Kbytes s agos IS 227 Entering Passive Mode 192 168 3 127 106 196 150 Opening ASCII mode data connection for bin ls T root root San o Mesi BAEN Nn SEW Tin IOO root 4996 Jun 12 02 15 teps2 release 226 Transfer complete ftp gt 2 16 1A240 241 Linux User s Manual Getting Started 3 From the IA240 241 type chmod x tcps2 release tcps2 release amp 192 168 3 1272 PuTTY root Moxa is al Chapa ae 2 root root 0 Jun 12 02 14 drwxr xr x I gt root Toot 0 Jan 1 1970 jj I root root 899 Jun 10 08 11 bash_history ji 1 root root 4996 Jun 12 02 15 tcps2 release root Moxa chmod x tcps2 release root Moxa ls al drwxr Kr x 2 root root 0 amin 2 02g ha Xr LS root TOOR Dean 1970 1 root root Ch dwa MO Ole losins EDER l root root Agee dum 12 02 15 root Moxa 4 The program should start running in the background Use the ps ef command to check if the tcps2 program is actually running in the background ps use this command to check if the program is running 192 168 3 127 PuTTY root Moxa la al dEWxr Xt A root root 0 Jun 12 02 14 DEWAELE KEK lo Toot Loot 0 Jan 1 190 Al root HOO SOS neva 10 OEL ern iate ry r r iL root root 4996 Jun 12 02 15 tcps2 release root Moxa chmod x tcps2 release root Moxa ls al drwxr xr x 2 root root 0 union i2 EWL XIS root MOO 0 Jan 1 rW il Too Hooi 899 Jun 10 bash_history be b
22. 27 139 udpLocalAddress 192 168 4 127 1026 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 1027 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 1027 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 9 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 9 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 161 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 161 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 4800 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 4800 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 854 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 854 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 111 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 111 ipaddress 192 168 4 127 udpLocalPort 192 168 27 139 1024 integer 1024 udpLocalPort 192 168 4 127 1024 integer 1024 udpLocalPort 192 168 27 139 2049 integer 2049 udpLocalPort 192 168 4 127 2049 integer 2049 udpLocalPort 192 168 27 139 1026 integer 1026 udpLocalPort 192 168 4 127 1026 integer 1026 udpLocalPort 192 168 27 139 1027 integer 1027 udpLocalPort 192 168 4 127 1027 integer 1027 udpLocalPort 192 168 27 139 9 integer 9 udpLocalPort 192 168 4 127 9 integer 9 udpLocalPort 192 168 27 139 161 integer 161 udpLocalPort 192 168 4 127 161 integer 161 udpLocalPort 192 168 27 139 4800 integer 4800 udpLocalPort 192 168 4 127 4800 integer 4800 udpLocalPo
23. Arai Ghai inenen nent meenten 4 16 NES Network Fil System 2 inserieren 4 19 Setting up the IA240 241 as an NFS Client ennen nv enne enorme envenvenvene 4 19 Mai ee ne san ee arte une ae eet en ao 4 19 SNMP 3222 wee A spanien ce R DA A 4 20 Open VPN 2222 ra ash eneen adhere 4 28 Development Tool Chains uusssusssnnnnonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 5 1 Einux Tool Ch in nesciant RER are aE seen tie ail 5 2 Steps for Installing the Linux Tool Chain annen envenvenneenenneeneenvenveneen 5 2 Compilation for Applications nnen annees eneenvenvencenvernenneenernvenvenvenvenvencenne 5 2 On Line Debugging with GDB iris enire seoa sera een ETE raaa i Ko s Snas 5 3 Windows Tool Cham san i a E O E E E E EEEE 5 4 System Requirements for Windows Tool Chain ennen enne enen eneenvenveneen 5 4 Steps for Installing Windows Tool Chain nennen envenvenneenenneeneenvenveneen 5 5 Usine the BASH Shell iseer teete ee ea reaa soe esia rE ra aAa Ee e aR Eaei 5 8 Compilation for Applications sersessersessessersnesennesnensennensennnnnennnennennsnensennnnnonennn 5 9 On Line Debugging with Insight ennen enveneenvenvenvenvernenneeneenvenveneen 5 11 Programmer s Gulde u u ee 6 1 Flash Memory Mapenor hectic a scars tehevseds E EEE EE EEEE sense 6 2 Devic API ns susanne nalen nam anchnnininenberie 6 2 RTG Real Time Clock aanrenden aa seits please Ha ede 6 2 Buzzer
24. Chain Other Host Packets Mangle Table FORWARD Chain Filter Table INPUT Chain Local Process Mangle Table OUTPUT Chain Filter Table FORWARD Chain Mangle Table POSTROUTING Chain NAT Table OUTPUT Chain Filter Table OUTPUT Chain NAT Table POSTROUTING Chain Outgoing Packets The IA240 241 supports the following sub modules Be sure to use the module that matches your application ip_conntrack ipt_MARK ipt_ah ipt_state ip_conntrack_ftp ipt MASQUERADE ipt esp ipt_tcpmss ipt_conntrack_irc ipt_MIRROT ipt_length ipt_tos ip_nat_ftp ipt_REDIRECT ipt_limit ipt_ttl ip_nat_irc ipt_REJECT ipt_mac ipt_unclean ip_nat_snmp_basic ipt_TCPMSS ipt_mark ip_queue ipt_TOS ipt_multiport ipt_LOG ipt_ULOG ipt_owner 4 9 1A240 241 Linux User s Manual Managing Communication NOTE The IA240 241 does NOT support IPV6 and ipchains NOTE The basic syntax to enable and load an IPTABLES module is as follows 1smod insmod ip_tables insmod iptable_filter Use lsmod to check if the ip_tables module has already been loaded in the IA240 241 Use insmod to insert and enable the module Use the following command to load the modules iptable_filter iptable_mangle iptable_nat insmod iptable filter Use iptables iptables restore iptables save to maintain the database IPTABLES plays the role of packet filtering or NAT Take care when setting u
25. 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 DIO error mode n break case DIO_ERROR_CONTROL printf DIO error control n break case DIO_ERROR_DURATION printf DIO error duratoin n case DIO_ERROR_DURATION_20MS 6 11 1A240 241 Linux User s Manual Programmer s Guide printf DIO error The duratoin is not a multiple of 20 ms n break return 0 Example 2 File Name tduration c Description The program indicates to connect DO1 to DII and program will change digital output state automatically at the fixed frequency then detect event change of the digital input state is high or low in different duration OK include lt stdio h gt include lt stdlib h gt include lt signal h gt include lt sys time h gt include lt fentl h gt include lt unistd h gt include lt pthread h gt include lt moxadevice h gt ifdef DEBUG define dbg printf x printf x else define dbg_printf x endif define DURATION_NUM 7 define TEST_NUM 10 static int ndin_StateChangeDetected
26. Mask 255 0 0 0 UP LOOPBACK RUNNING MTU 2000 Metric 1 RX packets 0 errors 0 dropped 0 overrun 0 pppO Link encap Point to Point Protocol inet addr 192 76 32 3 P t P 129 67 1 165 Mask 255 255 255 0 UP POINTOPOINT RUNNING MTU 1500 Metric 1 RX packets 33 errors 0 dropped 0 overrun 0 TX packets 42 errors 0 dropped 0 overrun 0 Now type ping z z z z where z z z z is the address of your name server This should work Here s what the response could look like waddington p ping 129 67 1 165 PING 129 67 1 165 129 67 1 165 56 data bytes 64 bytes from 129 67 1 165 icmp_seq 0 ttl 225 time 268 ms 64 bytes from 129 67 1 165 icmp_seq 1 ttl 225 time 247 ms 64 bytes from 129 67 1 165 icmp_seq 2 ttl 225 time 266 ms AC 129 67 1 165 ping statistics 3 packets transmitted 3 packets received 0 packet loss round trip min avg max 247 260 268 ms waddington 4 15 1A240 241 Linux User s Manual Managing Communication Try typing netstat nr This should show three routes something like this Kernel routing table Destination Gateway Genmask Flags Metric Ref Use iface 129 67 1 165 0 0 0 0 255 255 255 255 UH 0 0 6 ppp 127 0 0 0 0 0 0 0 255 0 0 0 U 0 0 0 lo 0 0 0 0 129 67 1 165 0 0 0 0 UG 0 0 6298 pppO If your output looks similar but doesn t have the destination 0 0 0 0 line which refers to the default route used for connections you may have run pppd without the defaultroute option At this point you
27. Overview U Software Architecture gt Journaling Flash File System JFFS2 gt Software Package 1A240 241 Linux User s Manual Introduction Overview The IA240 IA241 embedded computers which are designed for industrial automation applications feature 4 RS 232 422 485 serial ports dual Ethernet ports 4 digital input channels 4 digital output channels and a PCMCIA cardbus and SD socket The computers come in a compact IP30 protected industrial strength rugged chassis The DIN Rail vertical form factor makes it easy to install the A240 241 embedded computers in small cabinets This space saving feature also facilitates easy wiring and makes the IA240 241 the best choice as front end embedded controllers for industrial applications In addition to the standard models the A240 IA241 also come in wide temperature models The IA240 T and IA241 T have an operating temperature range of 40 to 75 C and are appropriate for harsh industrial automation environments The industrial mechanism of the IA240 IA241 design provides robust reliable computing Due to the RISC based architecture the IA240 IA241 will not generate a lot of heat when in use The high communication performance and fanless design make the IA240 1A241 ideal for industrial automation environments The IA240 241 computers use a Moxa ART 192 Mhz RISC CPU Unlike the X86 CPU which uses a CISC design the RISC architecture and modern semiconductor technology provide thes
28. another network One network is designated the inside network and the other is the outside network Typically the A240 241 connects several devices on a network and maps local inside network addresses to one or more global outside IP addresses and un maps the global IP addresses on incoming packets back into local IP addresses Click on the following link for more information about iptables and NAT http www netfilter org documentation HOWTO NAT HOWTO html NAT Example The IP address of LANI is changed to 192 168 3 127 you will need to load the module ipt MASQUERADE IP Netmask 192 168 3 100 24 Gateway 192 168 3 127 PC1 Linux or Windows LAN1 192 168 3 127 24 Embedded Computer LAN2 192 168 4 127 24 PC2 Linux or Windows IP Netmask 192 168 4 100 24 Gateway 192 168 4 127 NAT Area Private IP echo 1 gt proc sys net ipv4 ip_forward insmod ip_tables insmod iptable_ filter insmod ip_conntrack insmod iptable_nat insmod ipt_MASQUERADE iptables t nat A POSTROUTING o eth0 j SNAT to source 192 168 3 127 iptables t nat A POSTROUTING o eth0 s 192 168 3 0 24 j MASQUERADE orn uF WD PB 4 12 1A240 241 Linux User s Manual Managing Communication Enabling NAT at Bootup In most real world situations you will want to use a simple shell script to enable NAT when the 1A240 241 boots up The following script is an example bin bash If you put this shell scrip
29. 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 _ Next execute hello exe to generate hello release and hello debug which are described below hello release an ARM platform execution file created specifically to run on the IA240 241 hello debug an ARM platform GDB debug server execution file see Chapter 5 for details about the GDB debug tool 2 13 1A240 241 Linux User s Manual Getting Started NOTE Since Moxa s tool chain places a specially designed Makefile in the directory tmp example hello be sure to type the make command from within that directory This special Makefile uses the mxscale gcc compiler to compile the hello c source code for the Xscale environment If you type the make command from within any other directory Linux will use the x86 compiler for example cc or gcc Refer to Chapter 5 to see a Makefile example Uploading and Running the Hello Program Use the following commands to upload hello release to the A240 241 via FTP 1 From the PC type ftp 192 168 3 127 2 Use the bin command to set the transfer mode to Binary mode and then use the put command to initiate the file transfer ftp gt bin ftp gt put hello release 3 From the IA240 241 type chmod x hello release hello release The word Hello will be printed on the screen hello release Developing Your Fi
30. ascii characters or 26 TxBurst WPA pre shared key Setting 8 to 64 ascii characters WpaPsk Enables or disables TxBurst Setting Explanation 0 disable 1 enable TurboRate Enables or disables TurboRate Setting Explanation 0 disable 1 enable BGProtection Sets 11b 11g protection this function is for engineering testing only Setting Explanation 0 auto 1 always on 2 always off ShortSlot Enables or disables the short slot time Setting Explanation 2 10 1A240 241 Linux User s Manual Getting Started 0 disable 1 enable TxRate Sets the TxRate Setting Explanation Auto 1 Mbps 2 Mbps 5 5 Mbps 11 Mbps 6 Mbps 9 Mbps 12 Mbps 18 Mbps 24 Mbps 36 Mbps 48 Mbps 54 Mbps Slona Rl wl Nnfyes oe an p p N RTSThreshold Sets the RTS threshold Setting 1 to 2347 FragThreshold Sets the fragment threshold Setting 256 to 2346 SD Socket and USB for Storage Expansion Both the IA240 and IA241 provide an SD socket for storage expansion Moxa provides an SD flash disk for plug amp play expansion that allows users to plug in a Secure Digital SD memory card compliant with the SD standard V1 0 for up to 1 GB of additional memory space The SD socket is located
31. backup root Moxa mnt ramdisk ls al drwxr xr x 3 root root 1024 Jun 15 02 47 Chape sies ot MOE HOO 0 Sep 29 2004 Sa I root ropt 12288 Jun 15 02 45 lost found Zee te il root root 27263140 Jun 15 02 48 root Moxa mnt ramdisk upfirm usrfs backup Moxa IA240 upgrade firmware utility version 1 0 To check source firmware file context The source firmware file conext is OK This step will destroy all your firmware Cerveno 2 NAN 8 xe Now upgrade the file userdisk Format MTD device dev mtd3 MID device dev mtd3 erase 128 Kibyte 600000 100 complete Wait to write file Compleleted 100 Upgrade the firmware is OK 1A240 241 Linux User s Manual Managing Embedded Linux Enabling and Disabling Daemons The following daemons are enabled when the IA240 241 boots up for the first time snmpd SNMP Agent daemon rn Telnet Server Client daemon en Internet Daemons FTP Server Client daemon arten Secure Shell Server daemon DEREN Apache WWW Server daemon Type the command ps ef to list all processes currently running root Moxa cd etc root Moxa etc ps ef PD RUE VmSize Stat Command Loot 592 S toa Sl Loot SWN ksoftirgd 0 J Pogg SW lt events 0 root SW lt khelper root SW lt kblockd 0 root SW khubd root SW pdflush root SW pdflush root aio 0 root SW kswapd0 604 root SW mtdblockd 609 root SW pccardd GI seo SW pccardd 625 root SWN jf
32. can try using Telnet ftp or finger bearing in mind that you ll have to use numeric IP addresses unless you ve set up etc resolv conf correctly Setting up a Machine for Incoming PPP Connections PPPoE This first example applies to using a modem and requiring authorization with a username and password pppd dev ttyMO 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 um The first star lets everyone login The second star lets every host connect The pair of double quotation marks is to use the file etc passwd to check the password The last star is to let any IP connect The following example does not check the username and password pppd dev ttyMO 115200 crtscts modem 192 168 16 1 192 168 16 2 1 Connect IA240 241 s LAN port to an ADSL modem with a cross over cable HUB or switch 2 Login to the IA240 241 as the root user 3 Edit the file etc ppp chap secrets and add the following username hinet net password TD 44 Ti username hinet net password Gaaresses chap secrets line 1 of 3 33 username hinet net is the username obtained from the ISP to log in to the ISP account password is the corresponding password for the account 4 16 1A240 241 Linux User s Manual Managing Communication 4 Edit the file etc ppp pap secrets and add the fol
33. gz root Moxa mnt ramdisk tar xvzf php tar gz envvars envvars old Iahexejskel tekovalir Iteigjstel tetovai e oel instal lsh laid lib libmysqlclient atome Sor 2 lib libphp5 so lib libmysqlclient tears Malley ki psm 3020622 Ino dlaloverel Bors Zie Ors lib libjpeg so ao alas Sie lat oy Akai oye iol EKO 5 2 php php php ini Pronto eine root Moxa mnt ramdisk Step 5 Run install sh and select to install php root Moxa mnt ramdisk install sh Press the number 1 Install PHP package Uninstall PHP package ERIE start to install PrP Please wait Starting web server apache PHP install sucess root Moxa mnt ramdisk 4 6 1A240 241 Linux User s Manual Managing Communication Step 6 Test it Use the browser to access http 192 168 3 127 phpinfo php Z phpinfo Microsoft Internet Explorer DEK ERO SEO HAD RRB IAD RAG O O DAO An kmo 2 2 a UM HELD B http 192 168 27 139Yphpinfo php vl gez a A System Linux Moxa 2 6 9 ucO 1048 Tue May 9 15 56 02 CST 2006 armv4tl Build Date Apr 4 2006 22 12 06 Configure configure build i686 linux host arm linux target arm inux with Command apxs2 home victor ia 240 241 source_code user apacheinstall_me bin apxs with zib with gettext disable cgi enable force cgi redirect prefix home victor ia 240 241 source_codejuser php install_me with openssl with Imysal home
34. ia240241 1st_application Makefile Type make to compile the example code You will get the following response indicating that the example program was compiled successfully root serverll home ia240241 1st application root serverll Ist application pwd home ia240241 1st application root serverll lst_application 11 total 20 stut root root 514 Now 27 11 32 Makefile See il more soo ASS Now 27 MESSE See il were score Wild New 27 MURS ees root serverll lst_application make_ usr local arm linux bin arm linux gcc o tcps2 release tcps2 c usr local arm linux bin arm linux strip s tcps2 release usr local arm linux bin arm linux gcc o tcpsp release tcpsp c usr local arm linux bin arm linux strip s tcpsp release usr local arm linux bin arm linux gce ggdb o teps2 deb g tcps2 c usr local arm linux bin arm linux gcce ggdb o tcpsp debug tcpsp c root serverll lst_application 11 total 92 Ee root 514 Nov 27 52 Makefile rWXxr xr x root root 25843 Nov 27 208 Mn KE X root root 4996 Now 27 Lo Se root root 4554 Nov 27 BOA ies AC LwWwXr XL X root root 26823 Nov 27 208 SEWXE XE x root root 5396 Nov 27 109 Sa a root root 6164 Nov 27 355 LEBE root serverll lst_application 2 15 1A240 241 Linux User s Manual Getting Started Two executable files tcps2 release and tcps2 debug are created teps2 release an ARM platform execution file created specifically to run on the IA240 241 teps
35. 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 ie 255 255 255 0 U 0 0 0 ethl 192 168 8 0 Bi 255 255 255 0 U 0 0 0 eth0 4 34 5 Development Tool Chains This chapter describes how to install a tool chain in the host computer that you use to develop your applications In addition the process of performing cross platform development and debugging are also introduced For clarity the A240 241 embedded computer is called a target computer The following functions are covered in this chapter Linux Tool Chain gt gt gt Steps for Installing the Linux Tool Chain Compilation for Applications On Line Debugging with GDB LJ Windows Tool Chain gt VV VV System Requirements for Windows Tool Chain Steps for Installing Windows Tool Chain Using the BASH Shell Compilation for Applications On Line Debugging with Insight 1A240 241 Linux User s Manual Development Tool Chains Linux Tool Chain The Linux tool chain contains a suite of cross compilers and other tools as well as the libraries and header files that are necessary to compile your applications These tool chain components must be installed in your host computer PC running Linux We have confirmed th
36. s Manual Development Tool Chains On Line Debugging with Insight Insight is a graphical user interface that accompanies GDB the GNU Debugger was written in Tcl Tk by people working at Red Hat Inc and Cygnus Solutions Red Hat was generous enough to make Insight available for public use and continues to maintain the program Click on http sources redhat com insight for more information about using Insight or click on Help Topics under the Help menu to read the user manual File Run View Control Preferences Help E Fina a FRI Soe oC ro he m About GDB e Help Topics se sle 7 Source Window i Z Insight Index Microsoft Internet Explorer File Edit View Favorites Tools Help al De x 2 A Je Search MO DEl SE SEE Ir E 3 Address JE cuclusrilocalimescaleb share insight1 0 helptindex htm C UC usrilocal mxscaleb share insight1 O help index html Breakpoint Window Console Window Function Browser Locals Window Memory Window Register Window Sessions Source Window Stack Window Target Window Thread Window Watch Window 5 11 Programmer s This chapter includes important information for programmers The following functions are covered in this chapter Flash Memory Map Device API RTC Real Time Clock Buzzer WDT Watch Dog Timer UART DI DO Make File Example OUOOCOOOD 1A240 241 Linux User s Manual Programmer s Guide
37. the following line to etc resolv conf if the DNS server s IP address is 168 95 1 1 nameserver 168 95 1 1 10 120 53 100 PuTTY mmm root 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 140 115 1 31 nameserver 140 115 236 10 root Moxa etc ete nsswitch conf This file defines the sequence to resolve the IP address by using etc hosts file or etc resolv conf 4 2 1A240 241 Linux User s Manual Managing Communication Web Service Apache The Apache web server s main configuration file is etc apache conf httpd conf with the default homepage located at home httpd htdocs index html Save your own homepage to the following directory home httpd htdocs Save your CGI page to the following directory home httpd cgi bin Before you modify the homepage use a browser such as Microsoft Internet Explore or Mozilla Firefox from your PC to test if the Apache Web Server is working Type the LANI IP address in the browser s address box to open the homepage E g if the default IP address is still active type http 192 168 3 127 in the address box A http 192 168 13 23 Microsoft Internet Explorer DER Fie Edit View Favorites Tools Help A Q sack gt x 2 A Search 57 Favorites Q ee E 3 Address http 192 168 13 23 v Eco Links It works Int
38. yes break fi done IFS SoIFS if FOUND no then modprobe mname fi start 4 29 1A240 241 Linux User s Manual Managing Communication ifcfg_vpn if d dev net then mkdir dev net fi if r dev net tun then create a device file if there is none mknod dev net tun c 10 200 fi load modules tun and bridge mname tun module_up mname bridge module_up create an ethernet bridge to connect tap devices bretl addbr br0 brcetl addif br0 iface internal interface the bridge receives data from any port and forwards it to other ports i expr 0 while do generate a tap0 interface on tun openvpn mktun dev tap i connect tap device to the bridge brctl addif br0 tap i null ip address of tap device ifconfig tap i 0 0 0 0 promisc up i expr i 1 if i ge maxtap then break fi done null ip address of internal interface ifconfig iface 0 0 0 0 promisc up enable bridge ip ifconfig brO IPADDR netmask NETMASK broadcast BROADCAST ipf proc sys net ipv4 ip_forward enable IP forwarding echo 1 gt ipf echo ip forwarding enabled to cat ipf stop echo shutdown openvpn bridge ifcfg_vpn i expr 0 while do disconnect tap device from the bridge bretl delif br0 tap i openvpn rmtun dev tap i i expr i 1 if i ge maxtap th
39. 192 168 27 139 1025 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 4 127 1025 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 2049 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 4 127 2049 0 0 0 0 0 integer 0 tepConnRemPort 192 168 27 139 1026 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 1026 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 9 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 9 0 0 0 0 0 integer 0 tepConnRemPort 192 168 27 139 111 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 111 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 80 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 80 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 21 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 4 127 21 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 22 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 22 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 27 139 23 0 0 0 0 0 integer 0 tepConnRemPort 192 168 4 127 23 0 0 0 0 0 integer 0 tcpInErrs 0 counter 6 tcpOutRsts 0 counter 37224 udpInDatagrams 0 counter 434 udpNoPorts 0 counter 8 udpInErrors 0 counter 0 udpOutDatagrams 0 counter 903 udpLocalAddress 192 168 27 139 1024 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 1024 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 2049 ipaddress 192 168 27 139 udpLocalAddress 192 168 4 127 2049 ipaddress 192 168 4 127 udpLocalAddress 192 168 27 139 1026 ipaddress 192 168
40. 1A240 241 Linux User s Manual Second Edition April 2008 www moxa com product MOXAN 2008 Moxa Inc all rights reserved Reproduction without permission is prohibited 1A240 241 Linux User s Manual The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement Copyright Notice Copyright 2008 Moxa Inc All rights reserved Reproduction without permission is prohibited Trademarks MOXA is a registered trademark of Moxa Inc All other trademarks or registered marks in this manual belong to their respective manufacturers Disclaimer Information in this document is subject to change without notice and does not represent a commitment on the part of Moxa Moxa provides this document as is without warranty of any kind either expressed or implied including but not limited to its particular purpose Moxa reserves the right to make improvements and or changes 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 periodically made to the information herein to correct such errors and these changes
41. 2 eis T EET 6 2 WDT Watch Dog Timer annae onee oneeenersnenseerneenneenneenneenneenseenseenvernensnenneenneennvenneenneenneen 6 3 UAR 42 28 22 nan eenen atin anlage skin nanne arseen beden 6 7 DUDO nn anemie 2225 Hs RE EB a A ae la ieee 6 8 Make File Ex mple 2 7 35 22 32 52 nnee pet 6 15 Software LOCK GRPNBEPEREFEEMEFRSPERFERRERTERSBERFRETERCEUERRTELEFERUETERRSLFRERLFRERESERSELERFELEFERERER 7 1 WG FINDS i os sa E svaeveuhendvaeactetdunechaudebseskaseaueaieulstebareandstucdstuares 8 1 Windows UC Findet enne Re sei ee amblas ent aanbeet 8 2 Installing the Software annen onvoneenvenvenvenvernenneeneenvenvenvenvervenneenvenvenvenvenve 8 2 Broadcast Sed reh sroine aere a ia a E ER Bass E E in 8 4 Linux ucfnder aasin h a aat e ea Beh aa A ids elen a en aes 8 5 System Commands nnn 22 2 ae A 1 busybox V0 60 4 Linux normal command utility collection nennen enen enen A 1 File manager KO EEE EA Networks sus eine ies EEE rience heheh E E anke Wehe mamatidieieu nen Process 2 10 een Soothe arma lage SRH HEN ESBR Sn en Other Sint haved isan MMs Hea iar Beas ienke Mount aes 1 Introduction Moxa IA240 and IA241 are RISC based ready to run embedded computers Available features include four RS 232 422 485 serial ports dual 10 100 Mbps Ethernet ports PCMCIA SD socket for storage expansion and USB 2 0 host making IA240 241 ideal for your embedded applications The following topics are covered in this chapter U
42. 2 Type upramdisk to get the free space ram disk to save the package 192 168 3 127 PuTTY a root Moxa bin upramdisk root Moxa bin df h Filesystem dev mtdblock2 dev ram0 Size 8 0M 499 0k 6 0M 6 0M 6 0M 30 4M 16 0M dev mtdblock3 dev mtdblock3 dev mtdblock3 tmpfs dev ram1 root Moxa bin Used Available Use 6 0M 2 0M 75 Terme 456 0k 45 488 0k STOMER 488 0k 5 5M 8 488 0k Seo GE 0 30 4M 1 08 ESAM 4 5 Mounted on if var tmp home etc dev shm var ramdisk 1A240 241 Linux User s Manual Managing Communication Step 3 Download the PHP package from the CD ROM You can find the package in CD ROM target php php tar gz root Moxa bin cd mnt ramdisk root Moxa mnt ramdisk ftp 192 168 27 130 Cromupreroiceyel wor MSA AGS AS 220 vsrTPd 2 0 1 Name 192 168 27 130 r00 root 331 Please specify the password Password gt 0 Login success tulk Remote system type is UNIX Using binary mode to transfer files igor eel ce 250 Directory successfully changed Sip bin 200 Switching to Binary mode ftp gt get php tar gz local php tar gz remote php tar gz 200 PORT command successful Consider using PASV 150 Opening BINARY mode data connection for php tar gz 1789032 bytes 226 File send OK 1789032 bytes received in 0 66 secs 2 6e 03 Kbytes sec Pepe Step 4 utar the package To do this type the command tar xvzf php tar
43. 2 168 4 172 LAN2 192 168 4 174 local net 4 33 1A240 241 Linux User s Manual Managing Communication 2 Create a configuration file named A tun conf and an executable script file named A tun sh 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 A tun sh bin sh value after net is the subnet behind the remote peer route add net 192 168 4 0 netmask 255 255 255 0 gw 5 end Create a configuration file named B tun conf and an executable script file named B tun sh on OpenVPN B 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 B tun sh 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 Note that the parameter ifconfig defines the first argument as the local internal interface and the second argument as the internal interface at the remote peer Note that 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 3 Check the
44. 2 192 168 4 127 255 255 255 0 Use a cross over Ethernet cable to connect directly from your PC to the IA240 241 You should first modify your PC s IP address and netmask so that your PC is on the same subnet as one of 1A240 241 s two LAN ports For example if you connect to LAN 1 you can set your PC s IP address to 192 168 3 126 and 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 netmask to 255 255 255 0 To connect to a hub or switch connected to your local LAN use a straight through Ethernet cable The default IP addresses and netmasks are shown above To login type the Login name and password as requested The default values are both root Login root Password root 1A240 241 Linux User s Manual Getting Started cx Telnet 192 168 27 139 Moxa login root Password HHH Hitt HHH HHHHHHH HHHHHH Hit nn nun HHH Hitt HHH HHHH Hit Hitt Hitt Hitt Hit Hitt Hit Hitt HHH HHHH Hit Hit Hit HHHH HHHH Hut HHH HHH HHH HH HH HH Hit HH Hit HH HH HHHH HH HH HHH HH HH HH HH HHHH HE Ht HE HH HH HH HH HEHEHE HH HH OH HH HHH Hit HEHEH HH HH Hitt Hit HHH Hitt Hi HHH HHH uit Hitt Hit Hit HH Hit Hitt tit HH uit Hitt Hit Hit itt Hitt tit ann OH HHH HHHHHHHH TEETH Bun HIE For further information check Ihttp uuw moxa com root Moxa You can proceed with configuring the network settings of the target computer when you reach the
45. 2 debug an ARM platform GDB debug server execution file see Chapter 5 for details about the GDB debug tool NOTE If you get an error message at this point it could be because you neglected to put teps2 c and tcpsp c in the same directory The example Makefile we provide is set up to compile both tcps2 and tcpsp into the same project Makefile Alternatively you could modify the Makefile to suit your particular requirements Uploading and Running the tcps2 release Program Use the following commands to use FTP to upload teps2 release to the IA240 241 1 From the PC type ftp 192 168 3 127 2 Next use the bin command to set the transfer mode to Binary and the put command to initiate the file transfer ftp gt bin ftp gt put tcps2 release root serverll home ia240241 1st application root serverll 1st_application ftp 192 168 3 127 Connected to 192 168 3 127 220 Moxa FIP server Version wu 2 6 1 2 Mon Nov 24 12 17 04 CST 2003 ready 530 Please login with USER and PASS 530 Please login with USER and PASS KERBEROS V4 rejected as an authentication type Name LCP Alsi Selin 3 root 331 Password required for root Password 230 User root logged in Remote system type is UNIX Using binary mode to transfer files ttp kin 200 Type set to I ftp gt put tcps2 release local tcps2 release remote tcps2 release 277 Entering Passive Mode 192 168 3 127 82 253 150 Opening BINARY mode data connection for tcps2 release
46. 38400 rs232PortOutSpeed 4 integer 38400 rs232AsyncPortIndex l integer 1 1 rs232AsyncPortIndex 2 integer 2 2 rs232AsyncPortIndex 3 integer 3 3 rs232AsyncPortIndex 4 integer 4 4 rs232AsyncPortBits 1 integer 8 rs232AsyncPortBits 2 integer 8 rs232AsyncPortBits 3 integer 8 rs232AsyncPortBits 4 integer 8 rs232AsyncPortStopBits 1 integer one 1 rs232AsyncPortStopBits 2 integer one 1 rs232AsyncPortStopBits 3 integer one 1 rs232AsyncPortStopBits 4 integer one 1 rs232AsyncPortParity 1 integer none 1 rs232AsyncPortParity 2 integer none 1 rs232AsyncPortParity 3 integer none 1 rs232AsyncPortParity 4 integer none 1 rs232InSigPortIndex 1 2 integer 1 rs232InSigPortIndex 2 2 integer 2 rs232InSigPortIndex 3 2 integer 3 rs232InSigPortIndex 4 2 integer 4 rs232InSigPortIndex 1 3 integer 1 rs232InSigPortIndex 2 3 integer 2 rs232InSigPortIndex 3 3 integer 3 rs232InSigPortIndex 4 3 integer 4 rs232InSigPortIndex 1 6 integer 1 rs232InSigPortIndex 2 6 integer 2 rs232InSigPortIndex 3 6 integer 3 rs232InSigPortIndex 4 6 integer 4 rs232InSigName 1 2 integer cts 2 rs232InSigName 2 2 integer cts 2 rs232InSigName 3 2 integer cts 2 rs232InSigName 4 2 integer cts 2 rs232InSigName 1 3 integer dsr 3 rs232InSigName 2 3 integer dsr 3 rs232InSigName 3 3 integer dsr 3 rs232InSigName 4 3 integer dsr 3 1 2 3 4 1 2 3 4 1 2 3 4 rs232InSigName
47. 485 rs232OutSigState 2 1 integer of f 3 486 rs232OutSigState 3 1 integer of f 3 487 rs232O0utSigState 4 1 integer of f 3 488 rs232O0utSigState 1 4 integer of f 3 489 rs232O0utSigState 2 4 integer of f 3 490 rs232O0utSigState 3 4 integer of f 3 491 rs232OutSigState 4 4 integer off 3 492 snmpInPkts 0 counter 493 493 snmpOutPkts 0 counter 493 494 snmpInBadVersions 0 counter 0 495 snmpInBadCommunityNames 0 counter 0 496 snmpInBadCommunityUses 0 counter 0 497 snmpInASNParseErrs 0 counter 0 498 snmpInTooBigs 0 counter 0 499 snmpInNoSuchNames 0 counter 0 500 snmpInBadValues 0 counter 0 501 snmpInReadOnlys 0 counter 0 502 snmpInGenErrs 0 counter 0 503 snmpInTotalReqVars 0 counter 503 504 snmpInTotalSetVars 0 counter 0 505 snmpInGetRequests 0 counter 0 506 snmpInGetNexts 0 counter 506 507 snmpInSetRequests 0 counter 0 508 snmpInGetResponses 0 counter 0 509 snmpInTraps 0 counter 0 510 snmpOutTooBigs 0 counter 0 511 snmpOutNoSuchNames 0 counter 0 512 snmpOutBadValues 0 counter 0 513 snmpOutGenErrs 0 counter 0 514 snmpOutGetRequests 0 counter 0 515 snmpOutGetNexts 0 counter 0 516 snmpOutSetRequests 0 counter 0 517 snmpOutGetResponses 0 counter 517 518 snmpOutTraps 0 counter 0 519 snmpEnableAuthenTraps 0 integer disabled 2 SNMP QUERY FINISHED 4 27 1A240 241 Linux User s Manual Managing Communica
48. 8 40 04 11 192 168 13 23 8 4 UC Finder 1A240 241 Linux User s Manual UC Finder 3 When the search is complete the same information is displayed in the UC Finder window FQ UC Finder File Function About 2 Broadcast Search MAC Address IP ddress 1 14241 00 90 E8 40 04 11 192 168 13 23 Search Result 1 UC s NOTE UC Finder is designed to determine the IP addresses of all UC units connected to the same LAN the host that is running UC Finder To configure UC s IP addresses or other configuration parameters use Telnet over the network or connect directly to the serial Console port to access 1A240 241 s Console utility Linux ucfinder Copy ucfinder from the Documentation and Software CD to your Linux PC and then use the following command to start the program UC Finder will automatically locate all I A240 241 units on the LAN and then report their IP addresses ucfinder 8 5 A System Commands busybox V0 60 4 Linux normal command utility collection File manager Editor Network ESSN AM aw A AN cp ls In mount rm chmod chown chgrp sync mv pwd df mkdir rmdir vi cat zcat grep cut find more test sleep echo ping route netstat ifconfig tracerout tftp telnet ftp copy file list file make symbolic link file mount and check file system delete file change file owner amp group amp user change file owner
49. BOO root Moxa SWN SW lt SW lt SW lt SW SW SW SW SW SW SW Setting the Run Level In this section we outline the steps you should take to set the Linux run level and execute requests Use the following command to enable or disable settings algo LS kSo0ttirgd 0 events 0 khelper kblockd 0 khubd pdflush pdflush aio 0 kswapd0 mtdblockd pccardd pccaradd WE EEZ egel smeed bin inetd root tcps2 release usr bin httpd k start bin portmap bin sh login bin snmpd usr bin httpd usr bin httpd usr bin httpd usr bin httpd usr bin httpd bin reportip bash bin telnetd bash ps ef k Sk k k k Sika start start start Start d etc apache d etc apache d etc apache d etc apache d etc apache d etc apache root Moxa ect rc d rc3 d 1s S19nfs common S20snmpd Sbarssh S24pcmcia cd etc rc d init d S99rmnologin root Moxa etc rc d rc3 d S25nfs user serverS99showreadyled Edit a shell script to execute root tcps2 release and save to tcps2 as an example Hed etc rc d rc3 d ln s etc re d init d teps2 S60tcps2 SxxRUNFILE stands for S start the run file while linux boots up xx a number between 00 99 Smaller numbers have a higher priority RUNFILE the file name 1A240 241 Linux User s Manual Managing Embedded Linux 192 16872 127 PUTT root Moxa ect rc d rc3 d 1s Sl9nfs common S25nfs use
50. D will turn off after 5 seconds and the factory defaults will be loaded Backing Up the User Directory 1 Create a backup file First type the following command to enable the RAM disk upramdisk Next use the file system backup utility provided by Moxa backupuf mnt ramdisk usrfs backup 2 Once the file system is backed up use FTP to transfer the file usrfs backup to your PC 3 4 1A240 241 Linux User s Manual Managing Embedded Linux root Moxa upramdisk root Moxa cd mnt ramdisk root Moxa mnt ramdisk df h Filesystem Size Used Available Use Mounted on dev mtdblock2 8 0M 6 0M ZM 75 X dev ram0 499 0k 17 0k 457 0k 4 var dev mtdblock3 6 0M 488 0k 5 5M tmp dev mtdblock3 6 0M 488 0k 5 5M home dev mtdblock3 6 0M 488 0k 5 5M etc tmpfs 30 4M 0 30 4M dev shm dev raml 16 0M 120k 15 1 var ramdisk root Moxa mnt ramdisk backupuf mnt ramdisk usrfs backup Sync the file system Now backup the user root file system Please wait Backup user root file system OK root Moxa mnt ramdisk Deploying the User Directory to Additional IA240 241 Units For some applications you may need to ghost one IA240 241 user file system to other IA240 241 units Back up the user file system to a PC refer to the previous subsection Backing Up the User File System for instructions and then type the following commands to copy the backup to additional A240 241 units upramdisk cd mnt ramdisk upfirm usrfs
51. Edit PortManager Window Help a IA eee Sle Size En COM1 115200 Nane 2 1 vrinn ln B IM 2 Type vi interfaces to edit the network configuration file with vi editor You can configure the Ethernet ports of the IA240 241 for static or dynamic DHCP IP addresses Static IP addresses As shown below 4 network addresses must be modified address network netmask and broadcast The default IP addresses are 192 168 3 127 for LAN1 and 192 168 4 127 for LAN2 with default netmask of 255 255 255 0 We always want the loopback interface auto eth ethl lo iface lo inet loopback embedded ethernet LANI iface eth inet static address 192 168 3 127 network 192 168 3 0 netmask 299 299 299 0 broadcast 192 168 3 255 embedded ethernet LAN2 iface ethl inet static address 192 168 4 127 network 192 168 4 0 netmask 259 299 299 0 broadcast 192 168 4 259 802 119 Gigabyte Cardbus wireless card iface eth2 inet static address 192 168 5 127 network 192 168 5 0 etc network interfaces line 1 of 162 0 Se Se se 1A240 241 Linux User s Manual Getting Started Dynamic IP addresses By default the A240 241 is configured for static IP addresses To configure one or both LAN ports to request an IP address dynamically replace static with dhcp and then delete the address network netmask and broadcast lines Default Setting for LAN1 Dynamic Setting using DHCP iface eth0 inet static ifa
52. None 8 1 v T100 am dev ntdblock3 i 5 5M home f dev mtdblock3 7 5 5M fetc mp fs 30 4M dev shm RTS root Moxa df h Available Mounted on 2 0M 458 0k var 5M tmp 5M home SH fete 4M dev shm root Moxa A Got Break Signa If there isn t enough Available space for your application you will need to delete some existing files To do this connect your PC to the IA240 241 with the console cable and then use the console utility to delete the files from the IA240 241 s flash memory To check the amount of free space available look at the directories in the read write directory dev mtdblock3 Note that the directories home and etc are both mounted on the directory dev mtdblock3 NOTE If the flash memory is full you will need to free up some memory space before saving files to the Flash ROM Compiling Hello c The package CD contains several example programs Here we use Hello c as an example to show you how to compile and run your applications Type the following commands from your PC to copy the files used for this example from the CD to your computer s hard drive cd tmp mkdir example cp r mnt cdrom example tmp example To compile the program go to the Hello subdirectory and issue the following commands cd example hello make You should receive the following response root localhost hello make usr local arm linux bin arm linux gcc o hello release hello c usr local
53. OOSTA dat line 1 of 34 2Z2 State OPEN 2 8 1A240 241 Linux User s Manual Getting Started CountryRegion Sets the channels for your particular country region Setting Explanation 0 use channels 1 to 11 1 use channels 1 to 11 2 use channels to 13 3 use channels 10 11 4 use channels 10 to 13 5 use channel 14 6 use channels 1 to 14 7 use channels 3 to 9 WirelessMode Sets the wireless mode Setting Explanation 0 11b g mixed 1 11b only 2 11g only Setting SSID Sets the softAP SSID Any 32 byte string NetworkType Sets the wireless operation mode Setting Explanation Infra Infrastructure mode uses access points to transmit data Adhoc Adhoc mode transmits data from host to host Channel Sets the channel Setting Explanation 0 Auto 1 to 14 the channel you want to use AuthMode Sets the authentication mode Setting OPEN SHARED WPAPSK WPANONE 2 9 1A240 241 Linux User s Manual Getting Started EncrypType Sets encryption type Setting NONE WEP TKIP AES DefaultKeyID Sets default key ID Setting 1to4 KeylStr Key2Str Key3Str Key4Str Sets strings Keyl to Key4 Setting hex numbers The keys can be input as 5 ascii characters 10 hex numbers 13
54. O_LOW duration else if i 2 get now data printf DIN data for j 0 j lt MAX DIN PORT j 6 10 1A240 241 Linux User s Manual Programmer s Guide get_din_state j amp state printf s DataString state printf n printf DOUT data for j 0 j lt MAX_DOUT_PORT j get_dout_state j amp state printf s DataString state printf n else if i 3 set low to high event printf Please keyin the DIN number scanf d amp i printf Please input the DIN duration this minimun value must be over d MIN_DURATION scanf lu amp duration retval set_din_event i lowtohighevent DIN_EVENT_LOW_TO_HIGH duration else if i 4 clear event printf Please keyin the DIN number scanf d amp i retval set_din_event i NULL DIN EVENT CLEAR 0 else if i 5 set high data printf Please keyin the DOUT number scanf d amp i retval set_dout_state i 1 else if i 6 set low data printf Please keyin the DOUT number scanf d amp i retval set_dout_state i 0 else if i 7 quit break else if i 8 show event and duration printf Event n for j 0 j lt MAX DOUT PORT j retval get_din_event j amp i amp duration switch i case DIN EVENT HIGH TO
55. The other has some error to get the error code from errno int swtd_disable int fd Description Disable the application to ack sWatchDog And the kernel will be auto ack it User does not to do it at periodic Input int fd the file handle from swtd_open return value Output OK will be zero The other has some error to get error code from errno int swtd_get int fd int mode unsigned long time Description Get current setting values mode 1 for user application enable sWatchDog need to do ack 0 for user application disable sWatchdog does not need to do ack time The time period to ack sWatchDog Input intfd the file handle from swtd_open return value int mode the function will be return the status enable or disable user application need to do ack unsigned long time the function will return the current time period Output OK will be zero The other has some error to get error code from errno int swtd_ack int fd Description Acknowledge sWatchDog When the user application enable sWatchDog It need to call this function periodically with user predefined time in the application program Input int fd the file handle from swtd_open return value Output OK will be zero The other has some error to get error code from errno int swtd_close int fd Description Close the file handle 6 4 1A240 241 Linux User s Manual Programmer s Guide Input int fd
56. VPN 1A240 241 Linux User s Manual Managing Communication Telnet FTP DNS In addition to supporting Telnet client server and FTP client server the A240 241 also supports SSH and sftp client server To enable or disable the Telnet ftp server you first need to edit the file etc 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 1 Disabling the Telnet ftp server Disable the daemon by typing in front of the first character of the row to comment out the line The IA240 241 supports DNS client but not DNS server To set up DNS client you need to edit three configuration files ete hosts etc resolv conf and etc nsswitch conf etc hosts This is the first file that the Linux system reads to resolve the host name and IP address etc resolv conf This is the most important file that you need to edit when using DNS for the other programs For example before you use ntpdate time nist goc 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 the nameserver command For example add
57. a target The IA240 241 supports 3 types of IPTABLES table Filter tables NAT tables and Mangle tables A Filter Table includes three chains INPUT chain OUTPUT chain FORWARD chain 1A240 241 Linux User s Manual Managing Communication B NAT Table includes three chains PREROUTING 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 host can connect to Internet then other computers that connect to this host can connect to the Internet when the computer does not have an actual IP address REDIRECT a special form of DNAT that re sends packets to a local host independent of the destination IP address C Mangle Table includes two chains PREROUTING chain pre processes packets before the routing process OUTPUT chain processes packets after the routing process It has three extensions TTL MARK TOS The following figure shows the IPTABLES hierarchy 4 8 1A240 241 Linux User s Manual Managing Communication Incoming Packets Mangle Table PREROUTING Chain NAT Table PREROUTING Chain Local Host Packets Mangle Table INPUT
58. a null modem cable over a Telnet link and links established using a modem over a telephone line Modem PPP access is almost identical to connecting directly to a network through the 1A240 241 s Ethernet port Since PPP is a peer to peer system the IA240 241 can also use PPP to link two networks or a local network to the Internet to create a Wide Area Network WAN NOTE Click on the following links for more information about ppp http tldp org HOWTO PPP HOWTO index html http axion physics ubc ca ppp linux html The pppd daemon is used to connect to a PPP server from a Linux system For detailed information about pppd see the man page 4 13 1A240 241 Linux User s Manual Managing Communication Example 1 Connecting to a PPP server over a simple dial up connection The following command is used to connect to aPPP server by modem Use this command for old ppp servers that prompt for a login name replace username with the correct name and password replace password with the correct password Note that debug and defaultroute 192 1 1 17 are optional pppd connect chat v ATDT5551212 CONNECT ogin username word password dev ttyMO 115200 debug crtscts modem defaultroute If 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
59. add the following routing item route add net 192 168 4 0 netmask 255 255 255 0 dev eth0 To create an indirect connection to Host A from Host B you need to add the following routing item route add net 192 168 2 0 netmask 255 255 255 0 dev eth0 Now ping Host B from Host A by typing ping 192 168 4 174 A successful ping indicates that you have created a VPN system that only allows authorized users from one internal network to access users at the remote site For this system all data is transmitted by UDP packets on port 5000 between OpenVPN peers 7 To shut down OpenVPN programs type the command killall TERM openvpn 4 32 1A240 241 Linux User s Manual Managing Communication Setup 2 Ethernet Bridging for Private Networks on the Same Subnet 1 Set up four machines as shown in the following diagram local net LAN1 192 168 2 173 LAN1 192 168 2 171 j LAN2 192 168 8 173 Internet LAN1 192 168 8 174 LAN 192 168 4 172 LAN2 192 168 4 174 local net 2 The configuration procedure is almost the same as for the previous example The only difference is that you will need to comment out the parameter up in etc openvpn A tap0 br conf and etc openvpn B tap0 br conf Setup 3 Routed IP 1 Set up four machines as shown in the following diagram local net LAN1 192 168 2 173 LAN 192 168 2 171 LAN2 192 168 8 173 Internet LAN1 192 168 8 174 LAN 19
60. age was not previously installed select this option to install the package now e Reinstall If the package was previously installed select this option to install it again This will overwrite the previous installation e Uninstall If the package was previously installed select this option if you do NOT want to make any changes e Skip Ignores a package entirely regardless of whether it was previously installed or uninstalled Packages marked Skip are omitted from the Partial display 5 The Progress window opens The installer will install all packages that were selected This process could take from 5 to 30 minutes depending on the speed of your system When the installation completes the Complete the Installation window will appear 27 27 Moxa Setup Progress This page displays the progress of the installation Installing arm linux 1 0 1 ust local arm linux arm linux sys include config ipmi Progress Fr Total een Disk 5 7 1A240 241 Linux User s Manual Development Tool Chains 6 Checkmark Create icon on Desktop to place a Moxa BASH Shell icon on your desktop and then click on Finish 27 Moxa Linux Tool Chain Setup Create Icons Create Icons To create a icon for convenient access to the Moxa Linux Tool Chain IV Create icon on Desktop Cancel 7 Click on OK to complete the installation process Moxa Setup x Installation Complete Using the BASH Shell A command line in
61. ake Upload and run teps2 release in the background tcps2 release amp Check that the process is running jobs or ps ef Use a serial cable to connect PCI to the IA240 241 s serial port 1 Use an Ethernet cable to connect PC2 to the IA240 241 On PCI If running Windows use HyperTerminal 38400 n 8 1 to open COMn On PC2 Type telnet 192 168 3 127 4001 On PCI Type some text on the keyboard and then press Enter On PC2 The text you typed on PC1 will appear on PC2 s screen 00 AN Mi U The testing environment is illustrated in the following figure However note that there are limitations to the example program teps2 c 2 18 1A240 241 Linux User s Manual Getting Started NOTE Serial Rx The teps2 c application is a simple example designed to give users a basic understanding of the concepts involved in combining Ethernet communication and serial port communication However the example program has some limitations that make it unsuitable for real life applications 1 The serial port is in canonical mode and block mode making it impossible to send data from the Ethernet side to the serial side i e from PC 2 to PC 1 in the above example 2 The Ethernet side will not accept multiple connections 2 19 3 Managing Embedded Linux This chapter includes information about version control deployment updates and peripherals The information in this chapter will be particularly useful whe
62. ams and test them in the target computer cleanly 8 UC Finder UC Finder comes in handy if you forget the IP address of the target computer while you have a demand for troubleshooting field problems This utility works by sending a broadcast message over the LAN to search for IP addresses of target computers Two versions of UC Finder are provided The GUI version works in Windows environments and the command line utility works in Linux environments The following topics are covered in this chapter Q Windows UC Finder gt Installing the Software gt Broadcast Search QO Linux ucfinder 1A240 241 Linux User s Manual UC Finder Windows UC Finder The UC Finder utility is used to search the LAN or intranet for Moxa embedded computers Installing the Software 1 Once the Setup program starts running click on Next to proceed 18 Setup UC Finder Welcome to the UC Finder Setup D Wizard This will install UC Finder on your computer kt is recommended that you close all other applications before continuing Click Nest to continue or Cancel to exit Setup 2 Click on Next when the Select Additional Tools window opens to proceed with the installation el Setup UC Finder Select Additional Tasks Which additional tasks should be performed Select the additional tasks you would like Setup to perform while installing UC Finder then click Next Additional icons 8 2 1A240 241 Linux User
63. are incorporated into new editions of the publication Technical Support Contact Information www moxa com support Moxa Americas Moxa China Shanghai office Toll free 1 888 669 2872 Toll free 800 820 5036 Tel 1 714 528 6777 Tel 86 21 5258 9955 Fax 1 714 528 6778 Fax 86 10 6872 3958 Moxa Europe Moxa Asia Pacific Tel 49 89 3 70 03 99 0 Tel 886 2 8919 1230 Fax 49 89 3 70 03 99 99 Fax 886 2 8919 1231 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Table of Contents INTOQUELION sca svatsetsacetsceaseciavececcansenaucnscvsnaovasieue tasccnsavastunastunasseasuannsvarsanenaatesa 1 1 Overview aansneed Lahn neuen Gite en aes ead eee ce 1 2 Software Architecturen ese eoria eaaa aa o o A E Ea a E EE EAEE IE ETES 1 2 Journaling Flash File System JFFS2 annen eneen envenvenvenvenvenveenenneene 1 3 Software Packages 3 tien 5 enen tenere bhi Aedes draperen 1 4 Getting Started rn rennen eenen 2 1 Powering onthe TA240 2AT 2 22 ahnen rap teln EEEE EE EE oeb EKES 2 2 Connecting the JA240 241 tora PCEren nari aer rs oh eanrenensensehel keer alias 2 2 Serial Console nessen iten eae heen Reini wanes bats Petter nk 2 2 Telnet Consoles scvscisistessiasssvectsesteeshscuscasct sches falls psp 2 3 SSH Consolen 82 sen nenne AEE 2 4 Configuring the Ethernet Interface ann onvonvonvenvenveenenvenvervenneenvenvenvenvenvervenneenenne 2 6 Modifying Network Settings with the Serial Console annen eneen 2 6 Modifying Network Settin
64. at the following Linux distributions can be used to install the tool chain Fefora core 1 amp 2 Steps for Installing the Linux Tool Chain The tool chain needs about 485 MB of hard disk space To install it follow the steps 1 Insert the package CD into your PC and then issue the following commands mount dev cdrom mnt cdrom sh mnt cdrom tool chain linux install sh 2 Wait for the installation process to complete This should take a few minutes 3 Add the directory usr local arm linux bin to your path You can do this for the current login by issuing the following commands export PATH usr local arm linux bin PATH Alternatively you can add the same commands to HOME bash_profile to make it effective for all login sessions Compilation for Applications To compile a simple C application use the cross compiler instead of the regular compiler arm linux gec o example Wall g 02 example c arm linux strip s example arm linux gcc ggdb o example debug example c Most of the cross compiler tools are the same as their native compiler counterparts but with an additional prefix that specifies the target system In the case of x86 environments the prefix is i386 linux and in the case of 1A204 241 ARM boards it is arm linux For example the native C compiler is gee and the cross C compiler for ARM in the IA240 241 is arm linux gcc The following cross compiler tools are provided
65. ation xhtml xml text html q 0 9 text plain q 0 8 image png q 0 5 PATH_INFO PATH_TRANSLATED SCRIPT_NAME cgi bin test cgi QUERY STRING REMOTE HOST REMOTE_ADDR REMOTE_USER AUTH_TYPE CONTENT TYPE CONTENT LENGIE 192 168 3 105 4 4 1A240 241 Linux User s Manual Managing Communication NOTE file is executable 1927168 3 127 PUTTY The CGI function is enabled by default If you want to disable the function modify the file etc apache conf httpd conf When you develop your own CGI application make sure your CGI root Moxa home httpd cgi bin ls al drwxr xr x 2 teef meo 0 Aug 24 1999 5 rooe SOGE 0 Meme 5 leila ape ke X Al root foe 757 Aug 24 1999 root Moxa home httpd cgi bin drwxr xr x Install PHP for Apache Web Server This embedded computer supports the PHP option However since the PHP file is 3 MB it is not installed by default To install it yourself first make sure there is enough free space at least 3 MB on your embedded flash ROM Step 1 Check that you have enough free space 192 168 3 12 root Moxa Filesystem dev mtdblock2 dev ramO dev mtdblock3 dev mtdblock3 dev mtdblock3 tmpfs root Moxa bin Used Available Use 6 0M 2 0M 75 EROR 457 0k 4 488 0k 5 5M 8 488 0k 5 5M 8 488 0k 5 5M 8 0 30 4M Mounted on if var tmp home etc dev shm To check that the dev mtdblock3 free space is greater than 3 MB Step
66. can enable it or disable it When the user enables WDT but the application does not acknowledge it the system will reboot You can set the ack time from a minimum of 50 msec to a maximum of 60 seconds How the WDT works The sWatchDog is disabled when the system boots up The user application can also enable ack When the user does not ack it will let the system reboot Kernel boot User application running and enable user ack The user API The user application must include lt moxadevic h gt and link moxalib a A makefile example is shown below all arm linux gcc o xxxx xxxx c lmoxalib int swtd_open void Description Open the file handle to control the sWatchDog If you want to do something you must first to this And keep the file handle to do other Input None Output The return value is file handle If has some error it will return lt 0 value You can get error from errno int swtd_enable int fd unsigned long time Description Enable application sWatchDog And you must do ack after this process Input intfd the file handle from the swtd_open return value unsigned long time The time you wish to ack sWatchDog periodically You must ack the 6 3 1A240 241 Linux User s Manual Programmer s Guide sWatchDog before timeout If you do not ack the system will be reboot automatically The minimal time is 50 msec the maximum time is 60 seconds The time unit is msec Output OK will be zero
67. ce ethO inet dhcp address 192 168 3 127 network 192 168 3 0 netmask 255 255 255 0 broadcast 192 168 3 255 auto eth ethl lo iface lo inet loopback iface eth inet dhcp iface ethl inet dhcp 3 After the boot settings of the LAN interface have been modified issue the following command to activate the LAN settings immediately etc init d networking restart NOTE After changing the IP settings use the networking restart command to activate the new IP address Modifying Network Settings over the Network IP settings can be activated over the network but the new settings will not be saved to the flash ROM without modifying the file etc network interfaces For example type the command ifconfig eth0 192 168 1 1 to change the IP address of LANI to 192 168 1 1 root Moxa ifconfig eth 192 168 27 125 root Moxa Configuring the WLAN via the PCMCIA Interface IEEE802 11g The following IEEE802 11g wireless card modules are supported e ASUS WL 107g e CNET CWC 854 181D version e Edmiax EW 7108PCg e Amigo AWP 914W e GigaByte GN WMKG e Other brands that use the Ralink RT2500 series chip set To configure the WLAN for IEEE802 1 1g 2 7 1A240 241 Linux User s Manual Getting Started 3 Unplug the CardBus Wireless LAN card first Use the command vi etc networking interfaces to open the interfaces configuration file with vi editor and then edit the 802 11g network setti
68. change file group sync file system let system file buffer be saved to hardware move file display now file directly list now file system space make new directory delete directory text editor dump file context compress or expand files search string on file get string on file find file where are there dump file by one page test file exist or not sleep seconds echo string ping to test network routing table manager display network status set network ip address trace route 1A240 241 Linux User s Manual System Commands Process m Other INA Be NS kill ps dmesg sty zcat mknod free date env clear reboot halt du gzip gunzip hostname Moxa special utilities PN NE backupfs bf kversion cat etc version upramdisk downramdisk kill process display now running process dump kernel log message to set serial port dump gz file context make device node display system memory usage print or set the system date and time run a program in a modified environment clear the terminal screen reboot power off on the server halt the server estimate file space usage compress or expand files show system s host name backup file system user directory built the file system user directory show kernel version show user directory version mount ramdisk unmount ramdisk A 2
69. counter 0 icmpInSrcQuenchs 0 counter 0 icmpInRedirects 0 counter 0 icmpInEchos 0 counter 2 icmpInEchoReps 0 counter 0 icmpInTimestamps 0 counter 0 icmpInTimestampReps 0 counter 0 icmpInAddrMasks 0 counter 0 icmpInAddrMaskReps 0 counter 0 icmpOutMsgs 0 counter 144 icmpOutErrors 0 counter 0 icmpOutDestUnreachs 0 counter 135 icmpOutTimeExcds 0 counter 0 icmpOutParmProbs 0 counter 0 icmpOutSrcQuenchs 0 counter 0 icmpOutRedirects 0 counter 7 icmpOutEchos 0 counter 0 icmpOutEchoReps 0 counter 2 icmpOutTimestamps 0 counter 0 icmpOutTimestampReps 0 counter 0 icmpOutAddrMasks 0 counter 0 icmpOutAddrMaskReps 0 counter 0 tcpRtoAlgorithm 0 integer other 1 tcpRtoMin 0 integer 200 tcpRtoMax 0 integer 120000 tcpMaxConn 0 integer 1 tepActiveOpens 0 counter 0 tcpPassiveOpens 0 counter 0 tcpAttemptFails 0 counter 0 tcpEstabResets 0 counter 0 tcpCurrEstab 0 gauge 0 tepInSegs 0 counter 0 tcpOutSegs 0 counter 0 tcpRetransSegs 0 counter 0 tcpConnState 192 168 27 139 1024 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 1024 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 1025 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 1025 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 2049 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 2049 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 1026 0 0 0 0 0 integer liste
70. d save or delete a stored session O Telnet Saved Sessions _ Embedded Computer Default Settings 192 168 27 121 192 168 27 127 192 168 27 128 195 226 66 181 Embedded Computer Load Save Close window on exit Odlways O Never Only on clean exit From a Linux machine use the ssh command to access the IA240 241 s console utility via SSH ssh 192 168 3 127 Select yes to complete the connection root bee_notebook root ssh 192 168 3 127 The authenticity of host RSA key fingerprint is 8b ee ff 84 41 25 fc cd 2a f Are you sure you want to continue connection Vie AGN 6 Sho LZ can t be established LO delers Siig JL 2 Seles in Ne Zas yes no NOTE over the network SSH provides better security compared to Telnet for accessing the IA240 241 s console utility 1A240 241 Linux User s Manual Getting Started Configuring the Ethernet Interface The network settings of the IA240 241 can be modified with the serial console or online over the network Modifying Network Settings with the Serial Console In this section we use the serial console to configure the network settings of the target computer 1 Follow the instructions given in a previous section to access the Console Utility of the target computer via the serial console port and then type cd etc network to change directories Ei PComm Terminal Emulator COM1 115200 None 8 1 T100 3 ol xj Profile
71. describe the procedures you should follow to compile a project with the Windows tool chain First copy the source codes of your project in the Windows tool chain s installation directory In the example shown here we want to compile the hello example provided in our CD ROM We will copy the source code to UC which is the root directory of the Windows tool chain Check the root directory where you can find the hello directory Mkpasswd 1 d gt etc passwd Mkgroup 1 d gt etc group Note that the d switch is necessary for domain users S eel hss Sel totale Jared_Wu 4294967295 Spe al al Jared_Wu 4294967295 Teger Jared_Wu 4294967295 Tie Tonla Jared_Wu 4294967295 ILE ALO etc Jared_Wu mkpasswd 4 18 07 hello Jared_Wu 4294967295 a NEZ Anso ice Jared_Wu 4294967295 AY hile ilo g Jared_Wu 4294967295 Al 10712 moxa ba t Jared_Wu 4294967295 4 11 12 moxa ico Jared_Wu 4294967295 Al eme Jared_Wu 4294967295 0 Nov 4 11 06 usr Jared_Wu 4294967295 0 Nov 4 Ale v r drwxrwx drwxrwx drwx SWEEX NDwofFRPRPORrPNINWOL drwxrwx 1A240 241 Linux User s Manual Development Tool Chains Next enter the hello directory and invoke the make program that will execute the compilation instructions written in the Makefile to compile the hello project Jared_Wu 4294967295 0 Nov 4 11710 ete Jared_Wu mkpasswd O Nov 4 18 07 hello drwxrwx 7 6 Kan Pr rwxr x 1 Jared_Wu 4294967295 3262 Nov 4 11
72. domain users S Ihe Zeil total 9 drwxr xr x drwxr xr x drwxr xr x drwxr xr x en e drwxr xr x LWXr xr xX stephen_ mkpasswd Jan 10 2 24 stephen_ mkpasswd Jan 10 324 5 stephen_ mkpasswd Jan 10 48 bin stephen_ mkpasswd Jan 10 4 etc stephen_ mkpasswd Jan 10 02 tastte stephen_ mkpasswd O Jan 10 48 lib stephen_ mkpasswd bys Devo A 03 moxa bat stephen_ mkpasswd 3262 Jan 10 22 03 moxa ico stephen_ mkpasswd 0 Jan 10 19 48 tmp stephen_ mkpasswd 0 Jan 10 19 48 usr stephen_ mkpasswd 0 gew 1O Testa ven o LW r r drwxr xr x drwxr xr x drwxr xr x Ns Niel UE AN So System Requirements for Windows Tool Chain Your Windows OS must satisfy the following requirements Windows 2000 workstation or Windows XP professional Minimum of 500 MB of free hard drive space on a single drive CD ROM or equivalent Ethernet capabilty to upload application programs to the target computer Being able to log on as an administrator AnNRWN gt Windows username without spaces You will be using a BASH shell window to enter commands In addition for editing text files such as configuration files you should use vi editor Do NOT use WordPad which could cause problems when the files are transferred to a bona fide Linux environment 1A240 241 Linux User s Manual Development Tool Chains Steps for Installing Windows Tool Chain 1 Double click on the tool chain file to start the installtion process and choose N
73. dport Destination port number j Jump target Specifies the target of the rules i e how to handle matched packets For example ACCEPT the packet DROP the packet or LOG the packet Examples Example 1 Accept all packets from lo interface iptables A INPUT i lo j ACCEPT Example 2 Accept TCP packets from 192 168 0 1 iptables A INPUT i eth0 p tcp s 192 168 0 1 j ACCEPT Example 3 Accept TCP packets from Class C network 192 168 1 0 24 iptables A INPUT i eth0 p tcp s 192 168 1 0 24 j ACCEPT Example 4 Drop TCP packets from 192 168 1 25 iptables A INPUT i eth0 p tcp s 192 168 1 25 j DROP Example 5 Drop TCP packets addressed for port 21 iptables A INPUT i eth0 p tcp dport 21 j DROP Example 6 Accept TCP packets from 192 168 0 24 to IA240 241 s port 137 138 139 iptables A INPUT i ethO p tcp s 192 168 0 24 dport 137 139 j ACCEPT Example 7 Log TCP packets that visit A240 241 s port 25 4 11 1A240 241 Linux User s Manual Managing Communication NAT NOTE iptables A INPUT i eth0 p tcp dport 25 j LOG Example 8 Drop all packets from MAC address 01 02 03 04 05 06 iptables A INPUT i eth0 p all m mac mac source 01 02 03 04 05 06 j DROP NOTE In Example 8 remember to issue the command modprobe ipt_mac first to load module ipt_mac NAT Network Address Translation protocol translates IP addresses used on one network to different IP addresses used on
74. e embedded computers with a powerful computing engine and communication functions but without generating a lot of heat A 16 MB NOR Flash ROM and a 64 MB SDRAM give you enough memory to install your application software directly on the embedded computer In addition dual LAN ports are built right into the RISC CPU This network capability in combination with the ability to control serial devices makes the IA240 241 ideal communication platforms for data acquisition and industrial control applications The IA240 241 s pre installed Linux operating system OS provides an open software operating system for your software program development Software written for desktop PCs can be easily ported to the computer with a GNU cross compiler without needing to modify the source code The OS device drivers e g serial and buzzer control and your own applications can all be stored in the NOR Flash memory The IA240 241 Linux Series referred to here as A240 241 or as the target computer consists of two models IA241 LX with CardBus and IA240 LX which doesn t support CardBus Both models have exactly the same hardware and software features except for the PCMCIA CardBus provided by the IA241 LX Software Architecture The Linux operating system that is pre installed in the A240 241 follows the standard Linux architecture making it easy to accept programs that follow the POSIX standard Program porting is done with the GNU Tool Chain provid
75. e De Al naer IN 4996 Jun 12 root Moxa tcps2 release amp W ez start root Moxa ps 1 Running tcps2 release amp root Moxa NOTE Use the kill command for job number 1 to terminate this program kill 1 2 17 1A240 241 Linux User s Manual Getting Started ps ef use this command to check if the program is running 1 Running tcps2 release amp root Moxa ps ef PID Uid VmSize Stat Command root 532 8 inic 3 root SWN ksoftirqd 0 root SW lt events 0 root SW lt khelper root SW lt kblockd 0 root SW khubd root SW pdflush root SW pdflush OE aio 0 root SW kswapd0 604 root SW mtdblockd 609 root SW pccardd GL roor SW pccardd 625 root Merse ged med GIS eot 500 bin inetd 619 root 3004 usr bin httpd k d etc apache 682 bin 380 bin portmap 685 root LEG bin sh login GI Toot 464 bin snmpd 694 nobody 3012 usr bin httpd k start d etc apache 695 nobody 3012 usr bin httpd k start d etc apache 696 nobody 3012 usr bin httpd k start d etc apache 697 nobody SOZ usr bin httpd k start d etc apache 698 nobody SOLZ usr bin httpd k start d etc apache LOL root J52 bin reportip 714 root ELTS bash TAR 2 00 436 S bin telnetd WZ root Tia S bash 728 root 1264 S tcps2 release 129 root 1592 5 ps ef root Moxa NOTE Use the kill 9 command for PID 187 to terminate this program kill 9 187 Testing Procedure Summary Compile teps2 c m
76. e System is protected and cannot be changed by the user This type of setup creates a safe zone For more information about the memory map and programming refer to Chapter 5 Programmer s Guide Journaling Flash File System JFFS2 The Root File System and User directory in the flash memory is formatted with the Journaling Flash File System JFFS2 The formatting process places a compressed file system in the flash memory This operation is transparent to the user The Journaling Flash File System JFFS2 which was developed by Axis Communications in Sweden puts a file system directly on the flash instead of emulating a block device It is designed for use on flash ROM chips and recognizes the special write requirements of a flash ROM chip JFFS2 implements wear leveling to extend the life of the flash disk and stores the flash directory structure in the RAM A log structured file system is maintained at all times The system is always consistent even if it encounters crashes or improper power downs and does not require fsck file system check on boot up JFFS2 is the newest version of JFFS It provides improved wear leveling and garbage collection performance improved RAM footprint and response to system memory pressure improved concurrency and support for suspending flash erases marking of bad sectors with continued use of the remaining good sectors enhancing the write life of the devices native data compression inside th
77. e file system design and support for hard links 1 3 1A240 241 Linux User s Manual Introduction The key features of JFFS2 are Targets the Flash ROM Directly Robustness Consistency across power failures e No integrity scan fsck is required at boot time after normal or abnormal shutdown Explicit wear leveling e Transparent compression Although JFFS2 is a journaling file system this does not preclude the loss of data The file system will remain in a consistent state across power failures and will always be mountable However if the board is powered down during a write then the incomplete write will be rolled back on the next boot but writes that have already been completed will not be affected Additional information about JFFS2 is available at http sources redhat com jffs2 jffs2 pdf http developer axis com software jffs http www linux mtd infradead org Software Package Boot Loader Moxa private V1 2 Kernel Linux 2 6 9 Protocol Stack ARP PPP CHAP PAP IPv4 ICMP TCP UDP DHCP FTP SNMP V1 V3 HTTP NTP NFS SMTP SSH 1 0 2 0 SSL Telnet PPPoE OpenVPN File System JFFS2 NFS Ext2 Ext3 VFAT FAT OS shell command Bash Busybox Linux normal command utility collection Utilities tinylogin login and user manager utility telnet telnet client program ftp FTP client program smtpc
78. ed by Moxa In addition to Standard POSIX APIs device drivers for the USB storage buzzer and Network controls and UART are also included in the Linux OS 1 2 1A240 241 Linux User s Manual Introduction AP User Application Daemon Apache Telnet FTPD SNMP API Application Interface POSIX Socket Secure Socket Protocol Stack TCP IP UDP CMP ARP HTTP SNMP SMTP Device File Driver PCMCIA CF WLAN USB UART RTC LCM Keypad System Microkernel Hardware RS 232 422 485 Ethernet PCMCIA CompactFlash USB The IA240 241 s built in Flash ROM is partitioned into Boot Loader Linux Kernel Root File System and User directory partitions In order to prevent user applications from crashing the Root File System the IA240 241 uses a specially designed Root File System with Protected Configuration for emergency use This Root File System comes with serial and Ethernet communication capability for users to load the Factory Default Image file The user directory saves the user s settings and application To improve system reliability the A240 241 has a built in mechanism that prevents the system from crashing When the Linux kernel boots up the kernel will mount the root file system for read only and then enable services and daemons During this time the kernel will start searching for system configuration parameters via re or inittab Normally the kernel uses the Root File System to boot up the system The Root Fil
79. ed to a public network the external interfaces of the OpenVPN machines should be configured for static IPs or connect to another device such as a firewall or DSL box first openvpn genkey secret secrouter key Copy the file that is generated to the OpenVPN machine 4 28 1A240 241 Linux User s Manual Managing Communication 2 Generate a script file named openvpn bridge on each OpenVPN machine This script reconfigures interface eth1 as IP less creates logical bridge s and TAP interfaces loads modules enables IP forwarding etc bin sh ifacezethl defines the internal interface maxtap expr 1 defines the number of tap devices I e of tunnels IPADDR NETMASK BROADCAST it is not a great idea but this system doesn t support etc sysconfig network scripts ifcfg ethl ifcfg_vpn while read f1 f2 3 f4 r3 do if f1 iface a f2 iface a f3 inet a f4 static then i expr 0 while do if i gt 5 then break fi i expr i 1 read f1 f2 case f1 in address IPADDR f2 rt netmask NETMASK f2 VE broadcast BROADCAST f2 7 esac done break fi done lt etc network interfaces get the ip address of the specified interface mname module_up oIFS IFS IFS FOUND no for LINE in lsmod do TOK echo LINE cut d 1 if TOK mname then FOUND
80. en break fi done brcetl delif br0 iface 4 30 1A240 241 Linux User s Manual Managing Communication bretl delbr br0 ifconfig br0 down ifconfig iface SIPADDR netmask NETMASK broadcast BROADCAST killall TERM openvpn case 1 in start start stop stop 7 restart stop start x echo Usage 0 start stop restart exit 1 esac exit 0 Create link symbols to enable this script at boot time In s etc openvpn openvpn bridge etc rc d rc3 d S32vpn br for example In s etc openvpn openvpn bridge etc rc d rc6 d K32vpn br for example 3 Create a configuration file named A tap0 br conf and an executable script file named A tap0 br sh on OpenVPN A 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 A tap0 br sh bin sh value after net is the subnet behind the remote peer route add net 192 168 4 0 netmask 255 255 255 0 dev br0 end Create a configuration file named B tap0 br conf and an executable script file named B tap0 br sh on OpenVPN B 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 B tap0 br sh bin sh value after net is the subnet behind the remote
81. er s Manual Managing Communication Define policy for chain rules Usage iptables t tables P INPUT OUTPUT FORWARD PREROUTING OUTPUT POSTROUTING ACCEPT DROP P Set the policy for the chain to the given target INPUT For packets coming into the IA240 241 OUTPUT For locally generated packets FORWARD For packets routed out through the IA240 241 PREROUTING To alter packets as soon as they come in POSTROUTING To alter packets as they are about to be sent out Examples 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 In this example the policy accepts outgoing packets and denies incoming packets Append or delete rules Usage 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 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 network IP address or plain IP address sport Source port number d Destination address
82. erface mode Argument 3 mode will pass to the UART device driver and change it 2 Function MOXA_GET_OP_MODE int ioctl fd MOXA GET OP MODE amp mode Description Get the interface mode Argument 3 mode will return the interface mode There are two Moxa private ioctl commands for setting up special baudrates Function MOXA_SET_SPECIAL_BAUD_RATE Function MOXA_GET_SPECIAL_BAUD_RATE If you use this ioctl to set a special baudrate the termios cflag will be B4000000 in which case the B4000000 define will be different If the baudrate you get from termios or from calling tcgetattr is B4000000 you must call ioctl with MOXA_GET_SPECIAL_BAUD_RATE to get the actual baudrate Example to set the baudrate include lt moxadevice h gt include lt termios h gt struct termios term int fd speed fd open dev ttyM0 O_RDWR tcgetattr fd amp term term c_cflag amp CBAUD CBAUDEX term c_cflag B4000000 tcsetattr fd TCSANOW amp term speed 500000 ioctl fd MOXA SET SPECIAL BAUD RATE amp speed Example to get the baudrate include lt moxadevice h gt include lt termios h gt struct termios term int fd speed fd open dev ttyM0 O_RDWR tcgetattr fd amp term if term c_cflag amp CBAUD CBAUDEX B4000000 follow the standard termios baud rate define else ioctl fd MOXA_GET_SPECIAL_BAUD_RATE amp speed 6 7 1A240 241 Linux User
83. ernet To open the default CGI page type http 192 168 3 127 cgi bin test cgi in your browser s address box 4 3 1A240 241 Linux User s Manual Managing Communication 3 http 192 168 13 23 cgi bin test cgi Microsoft Internet Explorer Address amp http 192 168 13 23 cgi binftest cgi CGI 1 0 test script report arge is 0 argv is SERVER_SOFTWARE Apache 2 1 6 Unix mod_ss1 2 1 6 OpenS55L 0 9 8 PHP 5 0 5 SERVER_NAME 192 168 13 23 GATEWAY_INTERFACE CGI 1 1 SERVER_PROTOCOL HTTP 1 1 SERVER_PORT 80 REQUEST_METHOD GET HTTP_ACCEPT image gif image x xbitmap image jpeg image pjpeg application x shockwave flash PATH_INFO PATH_TRANSLATED SCRIPT_NAME cgi bin test cgi QUERY_STRING REMOTE HOST REMOTE ADDR 192 168 13 25 REMOTE USER AUTH TYPE CONTENT TYPE CONTENT LENGTH i i j Done Internet Is To open the default CGI test script report page type http 192 168 3 127 cgi bin test cgi in your browser s address box Mozilla Firefox File Edit View Go Bookmarks Tools Help E gt 808 A C tp21192 168 3 127kgbintest ei vl c CL Getting Started E Latest Headlines CGI 1 0 test script report argc is 0 argv is SERVER_SOFTWARE Apache 2 0 42 Unix SERVER_NAME localhost GATEWAY_INTERFACE CGI 1 1 SERVER_PROTOCOL HITP 1 1 SERVER_PORT 80 REQUEST METHOD GET HTTP_ACCEPT text xml application xml applic
84. ext 27 Moxa Linux Tool Chain Setup Welcome Moxa ThinkCore IA Linux Tool Chain V1 0 Thank you for selecting Moxa Linux Tool Chain Moxa Linux Tool Chain Copyright 2006 Moxa Systems Co Ltd http www moxa com Cancel 2 Browse to the directory where you prefer to set the root directory for the tool chain Options of All Users and Unix are recommended Then choose Next 27 Moxa Linux Tool Chain Setup Choose Installation Directory EIER Select Root Install Directory Select the directory where you want to install Also choose a few installation parameters Root Directory C Moxa T ool Chain Browse Install For Default Text File Type All Users Recommend C pos C Just Me Unix Recommend lt Back Cancel If you have installed a tool chain before its root directory would show up in the Root Directory text field If you continue the installation the new tool chain in a previous root directory would override the old one Choose a different directory to keep both tool chains 5 5 1A240 241 Linux User s Manual Development Tool Chains 3 Navigate to the directory where the packages of the tool chain reside By default it is on the CD ROM tool chain windows Choose Next to proceed 27 Moxa Linux Tool Chain Setup Select Local Package Directory EIER Select Local Package Directory Select the directory where the package files of Tool Chain exist Local Package Directory
85. fs2_gcd_mtd3 673 root 500 bin inetd 679 LOO 3004 usr bin httpd k start d etc apache 682 bin 380 bin portmap 685 root 1178 Manmanm Loen 690 root 464 bin snmpd 694 nobody SOUZ usr bin httpd k start d etc apache 695 nobody SML usr bin httpd k start d etc apache 696 nobody 3012 usr bin httpd k start d etc apache 697 nobody 3012 usr bin httpd k start d etc apache 698 nobody 3012 usr bin httpd k start d etc apache OL zoer 352 bin reportip 714 root aS bash 726 root 436 bin telnetd 727 root 1180 bash 783 root 628 ps ef root Moxa ect To run a private daemon you can edit the file rc local as follows cd etc re d vi rc local root Moxa cd etc rc d root Moxa etc rc d vi rc local Next use vi to open your application program We use the example program teps2 release and put it to run in the background bin sh Add you want to run daemon root tcps2 release amp 3 6 1A240 241 Linux User s Manual Managing Embedded Linux The enabled daemons will be available after you reboot the system root Moxa ps ef PID il 4 ds 14 24 25 21 26 604 609 611 625 672 674 679 682 685 690 694 695 696 697 698 701 714 126 VE 783 Uid VmSize Stat Command Door 592 5 root se ojohe root root root TOOK TOO root FOOL root root BOO root root root root bin root TOOL nobody nobody nobody nobody nobody root root root root
86. g Your First Application gt Testing Environment gt Compiling tcps2 c gt Uploading and Running the tcps2 release Program gt Testing Procedure Summary 1A240 241 Linux User s Manual Getting Started Powering on the IA240 241 Connect the SG wire to the shielded contact located in the upper left corner of the IA240 241 and then power on the computer by connecting it to the power adaptor It takes about 30 to 60 seconds for the system to boot up Once the system is ready the Ready LED will light up NOTE After connecting the IA240 241 to the power supply it will take about 30 to 60 seconds for the operating system to boot up The green Ready LED will not turn on until the operating system is ready A ATTENTION This product is intended to be supplied by a Listed Power Unit and output marked with LPS and rated 12 48 VDC 580 mA minimum requirements Connecting the 1A240 241 to a PC There are two ways to connect the IA240 241 to a PC through the Serial Console port or via Telnet over the network Serial Console The serial console port gives users a convenient way of connecting to the IA240 241 s console utility This method is particularly useful when using the computer for the first time The signal is transmitted over a direct serial connection so you do not need to know either of its two IP addresses in order to connect to the serial console utility Use the serial console port settings shown below
87. general option of the form x x x x y y y y Here x x x x is the local IP address and y y y y is the IP address of the remote end of the PPP connection If this option is not specified or if just one side is specified then x x x x defaults to the IP address associated with the local machine s hostname located in etc hosts and y y y y is determined by the remote machine Example 2 Connecting to a PPP server over a hard wired link If ausername and password are not required use the following command note that noipdefault is optional pppd connect chat v noipdefault dev ttyMO 19200 crtscts If a username and password is required use the following command note that noipdefault is optional and root is both the username and password pppd connect chat v user root password root noipdefault dev ttyMO 19200 crtscts How to check the connection Once you ve set up a PPP connection there are some steps you can take to test the connection First type sbin ifconfig The folder ifconfig may be located elsewhere depending on your distribution You should be able to see all the network interfaces that are UP pppO should be one of them and you should recognize the first IP address as your own and the P t P address or point to point address the address of your server Here s what it looks like on one machine lo Link encap Local Loopback inet addr 127 0 0 1 Beast 127 255 255 255
88. gineering force has developed this protection mechanism for your applications via data encryption The binary file associated with each of your applications needs to undergo an additional encryption process after you have developed it The process requires you to install an encryption key in the target computer 1 Choose an encryption key e g ABigKey and install it in the target computer by a pre utility program setkey setkey ABigKey Note set an empty string to clear the encryption key in the target computer by setkey lt 2 Develop and compile your program in the development PC 3 Inthe development PC run the utility program binencryptor to encrypt your program with an encryption key binencryptor yourProgram ABigKey 4 Upload the encrypted program file to the target computerby FTP or NFS and test the program The encryption key is a computer wise key That is to say a computer has only one key installed Running the program setkey multiple times causes the key to be overrided To prove the effectiveness of this software protection mechanism prepare a target computer that has not been installed an encryption key or install a key different from that used to encrypt your program In any case the encrypted program fails immediately This mechanism also allows the computer with an encryption key to bypass programs that are not encrypted Therefore in the development phase you can develop your progr
89. gs over the NetWork nennen enne oneenveneeneene 2 7 Configuring the WLAN via the PCMCIA Interface eene onvenvencenvenvenneenenne 2 7 IEEB802 118 4 222 252 2822058 isses eenn arseen AES 2 7 SD Socket and USB for Storage Expansion aen onvenvenvenvenveenernveneenvenvencenneenenneene 2 11 Test Program Developing Hello C aanne nereerneeenerseerneerneenneenneenneenneenseenserneennnn 2 12 Installing the Tool Chain Linux unsere enne enne enneenne enne enseenveeneesnensverseeenensnn 2 12 Checking the Flash Memory Space annen anne on enneenernvenvencenvervenneeneenenneeneen 2 13 Compiling Helo Carsi meneer tetanden acterende ebde taan eed aarde ke ennn 2 13 Uploading and Running the Hello Program nanne ennen enne eneenenneeneen 2 14 Developing Your First Application annen onee oneenn eenen eneesnerseerneerneenneenneenneenseenseenverneennen 2 14 Testing Environment nsv seh Bess E bne benee ensen 2 14 Compiling teps2 C snor erneer sans ua 2 15 Uploading and Running the tcps2 release Program annees eneenvenvenenn 2 16 Testing Procedure Summary nan onoenvenvenvenvernenneeneenvenvencenvervenneeneenvenvenven 2 18 Managing Embedded Linux uuussesesnnnnnnnnnnnnennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnenennn 3 1 System Version Information ann oneen enne onernvenvenvenvenvenveenenneenvenvenvencenvervenneeneenvenvencen 3 2 System Image B ckup 0u na ee sehn ses denderende 3 2 Upgrading the Firmware
90. iaeensakn he 3 2 Loads Factory Defaulis perene r ame Bares 3 4 Backing Up the User Directory nnen ennen enneeneenvenvenvenvervenneevenvenneenennee 3 4 Deploying the User Directory to Additional A240 241 Units cei eeeseeeeeeneeees 3 5 Enabling and Disabling Daemons nnn oneenvenvencenvervenneeneenvenvenvenvervenneenennvenvencenne 3 6 Setting the Rum Level tnt een ens a a iaa a 3 7 Adjusting the System Time eane e rne eea E E E E E E E e E E S 3 8 Setting the Time Manually e eeaeee e eatea ia a aeee atoe en ENE Aen Ep ERENER SO 3 8 NTP Clientside ROE ai eae aunt 3 9 Updating the Time Automatically ennen onne oneens envenvenvenvenneenennenneenennee 3 9 Cron Daemon to Execute Scheduled Commands aaneen enne enneenveenveenn 3 10 Managing Communications usssnssnnnnonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 4 1 Telnet FIP 2 44 22 22h le ee aioe hoy durende haden 4 2 DNS icine Maine ee Ai kaat AA ine eA ed eh abn eenn HERE RZ 4 2 Web Service A pache artsen uses atten entente leertaken 4 3 Install PHP for Apache Web Server ann oneens envenvenveenenvenvervenneeneenvenvenvenvervenneenennee 4 5 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Appendix A NAT ses ar RE A eee 4 12 NAT Example orentis levi socnscecevi A A arken senen 4 12 Enabling NAT at Bootup nnen oneenvenvencenvernenneeneenvenvencenvervencenvervenneeneen 4 13 Dial upService PPP nutans ninth ate IRA BATE 4 13 PPPOE 3325 Sos Sad
91. j victorfia 240 241 source_code user mysal install_me with config file path etc apache php with gd home victor ia 240 1241 source_code lib libgd install_me with ibxml dir home victor ia 240 241 source_code lib libxml2 install_me Server API Apache 2 0 Handler Virtual disabled Directory Support Configuration etc apache php php ini File php ini Path PHP API 20031224 PHP Extension 20041030 Zend Extension 220040412 Debug Build no Thread Safety dsabled Zend Memory enabled Manager IPv6 Support enabled Registered PHP php fie http ftp compress zlib https ftps Streams Registered tep udp unix udg ssl ssiv3 ssiv2 tls Stream Socket Transports This program makes use of the Zend Scripting Language Engine Powered By Zend Engine v2 0 5 Copyright c 1998 2004 Zend Technologies PHP Credits ER ara lt If you want to uninstall PHP follow steps 2 to 5 but select the uninstall option IPTABLES IPTABLES is an administrative tool for setting up maintaining and inspecting the Linux kernel s IP packet filter rule tables Several different tables are defined with each table containing built in chains and user defined chains Each chain is a list of rules that apply to a certain type of packet Each rule specifies what to do with a matching packet A rule such as a jump to a user defined chain in the same table is called
92. k 16 0k 458 0k 3 var dev mtdblock3 6 0M 488 0k 5 5M 8 tmp dev mtdblock3 6 0M 488 0k 5 5M 8 home dev mtdblock3 6 0M 488 0k 5 5M 8 etc tmpfs 30 4M 0 30 4M 0 dev shm dev raml 16 0M Lets 15 UM 0 mnt ramdisk root Moxa cd mnt ramdisk root Moxa mnt ramdisk The following instructions give the steps required to save the firmware file to the A240 241 s RAM disk and how to upgrade the firmware 1 Type the following commands to enable the RAM disk upramdisk cd mnt ramdisk 2 Type the following commands to use the IA240 241 s built in FTP client to transfer the firmware file ia240 x x x frm or ia241 x x x frm from the PC to the IA240 241 mnt ramdisk gt ftp lt destination PC s IP gt Login Name xxxx Login Password xxxx ftp gt bin ftp gt get ia240 x x x frm root Moxa mnt ramdisk ftp 192 168 3 193 C nnected to UL Se Be 192 168 3 1937 220 TYPSoft FIP Server 1 10 ready Name GLE Se 193 rooty root 331 Password required for root Password 230 User root logged in Remote system type is UNIX Using binary mode to transfer files ftp gt cd newsw 250 CWD command successful C ftproot newsw is current directory fer kin 200 Type set to I tepa is 200 Port command successful 150 Opening data connection for directory list drw rw rw 1 ep ftp O Nov 20102023 drw rw rw L iea SES O Now 3010203 LW LW rW I FEB ftp 13167772 Now 23 10324 1az20 1 0 Eem 226 Transfer comp
93. lete ftp gt get ia240 1 0 frm local 1a240 1 0 rm remote 1la240 1 0 2rm 200 Port command successful 150 Opening data connection for ia240 1 0 frm 226 Transfer complete 1A240 241 Linux User s Manual Managing Embedded Linux 13167772 bytes received in 2 17 secs 5925 8 kB s ftp 3 Next use the upfirm command to upgrade the kernel and root file system upfirm ia240 x x x frm 192 16873 127 PuTTY root Moxa mnt ramdisk upfirm ia240 1 0 frm Moxa IA240 upgrade firmware utility version 1 0 To check source firmware file context The source firmware file conext is OK This step will destroy all your firmware Corme imas 2 WADE A u Now upgrade the file kernel Format MTD device dev mtd1 MTD device dev mtdl erase 128 Kibyte 1C0000 100 complete Wait to write file Compleleted 100 Now upgrade the file usrdisk Format MID device dev mtd2 MTD device dev mtd2 erase 128 Kibyte 800000 100 complete Wait to write file Compleleted 100 Upgrade the firmware is OK ATTENTION The upfirm utility will reboot your target after the upgrade is OK Loading Factory Defaults To load the the factory default settings you must press the reset to default button for more than 5 seconds All files in the home amp etc directories will be destroyed Note that while pressing the reset to default button the Ready LED will blink once every second for the first 5 seconds The Ready LE
94. lient email utility scp Secure file transfer Client Program Daemons pppd dial in out over serial port daemon snmpd snmpd agent daemon telnetd telnet server daemon inetd TCP server manager program ftpd ftp server daemon apache web server daemon sshd secure shell server openvpn virtual private network openssl open SSL Linux Tool Chain Gcc V3 3 2 C C PC Cross Compiler GDB V5 3 Source Level Debug Server Glibc V2 2 5 POSIX standard C library Windows Tool Chain Gee V3 3 2 C C PC Cross Compiler Glibc V2 2 5 POSIX standard C library Insight V6 1 Windows environment source level debug utility 1 4 2 Getting Started In this chapter we explain how to connect the A240 241 how to turn on the power how to get started programming and how to use the A240 241 s other functions The following topics are covered in this chapter U Powering on the IA240 241 Q Connecting the IA240 241 to a PC gt Serial Console gt Telnet Console gt SSH Console Q Configuring the Ethernet Interface gt Modifying Network Settings with the Serial Console gt Modifying Network Settings over the Network Q Configuring the WLAN via the PCMCIA Interface gt TEEE802 11g Q SD Socket and USB for Storage Expansion U Test Program Developing Hello c gt Installing the Tool Chain Linux gt Checking the Flash Memory Space gt Compiling Hello c gt Uploading and Running the Hello Program Q Developin
95. lowing username hinet net password password if you don t use the login option of pppd The mgetty Debian package already provides this option make sure you don t change that INBOUND connections Every regular user can use PPP and has to use passwords from etc passwd i gt username hinet net password UserIDs that cannot use PPP at all Check your etc passwd and add any other accounts that should not be able to use pppd guest hostname eee master hostname x root hostname support hostname stats hostname OUTBOUND connections Here you should add your userid password to connect to your providers via PAP The means that the password is to be used for ANY host you connect to Thus you do not have to worry about the foreign machine name Just replace password with your password pap secrets line 1 of 42 2 username hinet net is the username obtained from the ISP to log in to the ISP account password is the corresponding password for the account 5 Edit the file etc ppp options and add the following line plugin pppoe terminated because it was idle holdoff lt n gt Wait for up n milliseconds after the connect script finishes for a valid PPP packet from the peer At the end of this time or when a valid PPP packet is received from the peer pppd will commence negotiation by sending its first LCP packet The default value is 1000 1 second
96. msec struct timeval time time tv_sec msec 1000 time tv_usec msec 1000 1000 select 1 NULL NULL NULL amp time static int swtdfd static int stopflag 0 static void stop_swatchdog stopflag 1 static void do_swatchdog void swtd_enable swtdfd 500 while stopflag 0 mydelay 250 swtd_ack swtdfd swtd_disable swtdfd int main int argc char argv pid_t sonpid signal SIGUSR1 stop swatchdog swtdfd swtd_open if swtdfd lt 0 printf Open sWatchDog device fail n exit 1 if sonpid fork 0 do_swatchdog do user application main function end user application kill sonpid SIGUSR1 swtd_close swtdfd exit 1 The makefile is shown below all arm linux gcc o xxxx xxxx c lmoxalib 6 6 1A240 241 Linux User s Manual Programmer s Guide UART The normal tty device node is located at dev ttyMO ttyM3 The IA240 241 supports Linux standard termios control The Moxa UART Device API allows you to configure ttyMO to ttyM3 as RS 232 RS 422 4 wire RS 485 or 2 wire RS 485 IA240 241 supports RS 232 RS 422 2 wire RS 485 and 4 wire RS485 You must include lt moxadevice h gt define RS232_MODE 0 define RS485_2WIRE_MODE 1 define RS422_MODE 2 define RS485_4WIRE_MODE 3 1 Function Moxa_SET_OP_MODE int ioctl fd MOXA SET OP MODE amp mode Description Set the int
97. n 2 tcpConnState 192 168 4 127 1026 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 9 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 9 0 0 0 0 0 integer listen 2 4 23 1A240 241 Linux User s Manual Managing Communication 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 tcpConnState 192 168 27 139 111 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 111 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 80 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 80 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 21 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 21 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 22 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 22 0 0 0 0 0 integer listen 2 tcpConnState 192 168 27 139 23 0 0 0 0 0 integer listen 2 tcpConnState 192 168 4 127 23 0 0 0 0 0 integer listen 2 tepConnLocalAddress 192 168 27 139 1024 0 0 0 0 0 ipaddress 192 168 27 139 tepConnLocalAddress 192 168 4 127 1024 0 0 0 0 0 ipaddress 192 168 4 127 tepConnLocalAddress 192 168 27 139 1025 0 0 0
98. n you need to run the same application on several TA240 241 units The following topics are covered in this chapter u m Ooo System Version Information System Image Backup gt Upgrading the Firmware gt Loading Factory Defaults gt Backing Up the User Directory gt Deploying the User Directory to Additional IA240 241 Units Enabling and Disabling Daemons Setting the Run Level Adjusting the System Time gt Setting the Time Manually gt NTP Client gt Updating the Time Automatically Cron Daemon to Execute Scheduled Commands 1A240 241 Linux User s Manual Managing Embedded Linux System Version Information NOTE To determine the hardware capability of your A240 241 and what kind of software functions are supported check the version numbers of your IA240 241 s hardware kernel and user file system Contact Moxa to determine the hardware version You will need the Production S N Serial number which is located on the A240 241 s bottom label To check the kernel version type kversion 192 T6873 T27 PUTTY root Moxa kversion Version 1 0 root Moxa The kernel version number is for the factory default configuration and if you download the latest firmware version from Moxa s website and then upgrade the IA240 241 s hardware System Image Backup Upgrading the Firmware A ATTENTION The IA240 241 s bios kernel and root file system are combined into one firmwa
99. ndout_StateChangeDetected static int nDuration static unsigned long duration 2 DURATION_NUM 50 40 35 30 25 20 15 160 140 120 100 80 60 40 RR KKK IKK KKK KK KK e 2 2 21202 22 2 2 202202 2 2 2 212 2 2 2 2 2 2 2202 2 2 KKK KKK 2 222 2 2 2 2 2 2 2 2 22 When the din state changed form high to low this function will be invoked FI KK KKK IK HK e e KKK HK KKK 2 2 202 2 2 2 KK 2 2 2 2 2 212 2 2 22 2 2 2 22 2 2 222 2 2 2 2 2212 22 22 2 2 2 2 27 static void low2highevent int diport ndin_StateChangeDetected dbg_printf din state changed d n ndin_StateChangeDetected KKK KK KK KKK KKK 2 e 2 2 20212 22 2 2 202202 2 2 2 212 202 2 2 2 2 2 202 2 2 222 22 2 2 222 22 2 2 22 2 2022 This function is used to exchange the dout state periodically FHKE IK IKK KK KK KK KK KK KKK KK KK 2 2 2 212212 2 2 2 21222 2 2 2 2222 2 2 22 2 2 2 2 2 2212 22 2 KK KKK A void dout_control int signo int state get_dout_state 0 amp state dbg_printf dout state changed d n state if state exchange the dout state periodically ndout_StateChangeDetected set_dout_state 0 0 else set dout state 0 1 6 12 1A240 241 Linux User s Manual Programmer s Guide void dio_test_function void struct itimerval value int j i nChoice struct timeval tv do printf 0 Test for Din duration 0 n printf 1 Test for Din duration 0 n printf 9 Quit n
100. ngs circled in red in the following figure cx Telnet 192 168 2 ol address 192 168 3 127 network 192 168 3 8 netmask 255 255 255 8 broadcast 192 168 3 255 embedded ethernet LAN2 iface ethi inet static address 192 168 4 127 network 192 168 4 0 netmask 255 255 255 8 broadcast 192 168 4 255 Ht Wireless WiFi gt LAN 4face eth2 inet static address 192 168 5 127 network 192 168 5 8 netmask 255 255 255 8 broadcast 192 168 5 255 Ht An example ethernet card setup broadcast and gateway are optional Ht auto eth Ht iface eth inet static etc network interfaces line 24 of 162 147 Additional WLAN parameters are contained in the file RT2500STA dat To open the file navigate to the RT2500STA folder and invoke vi or type the command vi etc Wireless RT2500STA RT2500STA dat to edit the file with vi editor Options for the various parameters are listed below the figure 4 PComm Terminal Emulator COM1 115200 None 8 1 T100 Profile Edit PortManaser Window Help al ala Slelsijzs e si2e M1 115200 None 8 1 Y T100 Default ore CountryRegion 0 RTS irelessMode 0 SSID any etworkType Infra Channel 0 utchMode PEN EncrypType NONE efaultKeyIP 1 eylStr 0123456789 eyZStr ey3Str ey4aStr paPsk sabcdefghijklmnopyrstuvwaxyz TxBurst 0 TurboRate 0 GProtection 0 ShortSlot 0 TxRate 0 RTSThreshold 2312 FragThreshold 2312 SMode Can fetc Wireless RTZSOOSTA SRTZS
101. nment variable in the crontab if such a user exists Modify the file etc cron d crontab to set up your scheduled applications Crontab files have the following format mm h dom mon dow user command min hour date month week user command 0 59 0 23 1 31 1 12 0 6 0 is Sunday The following example demonstrates how to use Cron How to use cron to update the system time and RTC time every day at 8 00 STEP1 Write a shell script named fixtime sh and save it to home bin sh ntpdate time nist gov hwclock systohc exit 0 STEP2 Change mode of fixtime sh chmod 755 fixtime sh STEP3 Modify etc cron d crontab file to run fixtime sh at 8 00 every day Add the following line to the end of crontab 8 root home fixtime sh STEP4 Enable the cron daemon manually etc init d cron start STEPS Enable cron when the system boots up Add the following line in the file etc init d rc local etc init d cron start 3 10 4 Managing Communications In this chapter we explain how to configure the A240 241 s various communication functions The following topics are covered in this chapter OOOOODd Ooo Ooo Telnet FTP DNS Web Service Apache Install PHP for Apache Web Server IPTABLES NAT gt NAT Example gt Enabling NAT at Bootup Dial up Service PPP PPPoE NFS Network File System gt Setting up the IA240 241 as an NFS Client Mail SNMP Open
102. on the front panel of the 1A240 241 To install an SD card you must first remove the SD protection cover to access the socket and then plug the SD card directly into the socket Remember to press on the SD card first if you want to remove it The SD card will be mounted at mnt sd In addition to the SD socket a USB 2 0 host is located on the front panel The USB host is also designed for storage expansion To expand the storage by USB flash disk you just need to plug the USB flash disk into this USB port The flash disk will be detected automatically and its file partition will be mounted into the OS The USB storage will be mounted at mnt usbstorage 1A240 241 Linux User s Manual Getting Started Test Program Developing Hello c In this section we use the standard Hello programming example to illustrate how to develop a program for the IA240 241 In general program development involves the following seven steps Step 1 A Connect the IA240 241 to a Linux PC Step 2 Install Tool Chain GNU Cross Compiler amp glibc Step 3 Set the cross compiler and glibc environment variables Step 4 Code and compile the program Step 5 Download the program to the IA240 241 Via FTP or NFS Step 6 Debug the program gt If bugs are found return to Step 4 gt If no bugs are found continue with Step 7 Step 7 Back up the user directory distribute the program to additional IA240 241 units if needed Cross Compile
103. ore information about smtpclient http www engelschall com sw smtpclient To send an email message use the smtpclient utility which uses SMTP protocol Type smtpclient help to see the help message Example smtpclient s test f sender company com S IP_address receiver company com lt mail body message s The mail subject f Sender s mail address S SMTP server IP address The last mail address receiver company com is the receiver s e mail address mail body message is the mail content The last line of the body of the message should contain ONLY the period character You will need to add your hostname to the file etc hosts 4 19 1A240 241 Linux User s Manual Managing Communication SNMP The IA240 241 has built in SNMP V1 Simple Network Management Protocol agent software It supports RFC1317 RS 232 like group and RFC 1213 MIB II The following simple example allows you to use an SNMP browser on the host site to query the 1A240 241 which is the SNMP agent The IA240 241 will respond wees SNMP QUERY STARTED sysDescr 0 octet string Version 1 0 sysObjectID 0 object identifier enterprises 8691 12 240 sysUpTime 0 timeticks 0 days 03h 50m 11s 00th 1381100 sysContact 0 octet string Moxa Systems Co LDT sysName 0 octet string Moxa sysLocation 0 octet string Unknown sysServices 0 integer 6 ifNumber 0 integer 6 ifIndex 1 integer 1
104. p the IPTABLES rules If the rules are not correct remote hosts that connect via a LAN or PPP may be denied access We recommend using the Serial Console to set up the IPTABLES Click on the following links for more information about iptables http www linuxguruz com iptables http www netfilter 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 ttables Table to manipulate default filter example nat or filter L chain ListList all rules in selected chains If no chain is selected all chains are listed n Numeric output of addresses and ports iptables t tables FXZ F Flush the selected chain all the chains in the table if none is listed X Delete the specified user defined chain Z Set the packet and byte counters in all chains to zero Examples iptables L n In this example since we do not use the t parameter the system uses the default filter table Three chains are included INPUT OUTPUT and FORWARD INPUT chains are accepted automatically and all connections are accepted without being filtered iptables F iptables X iptables Z 4 10 1A240 241 Linux Us
105. peer route add net 192 168 2 0 netmask 255 255 255 0 dev br0 end Note Select cipher and authentication algorithms by specifying cipher and auth To see 4 31 1A240 241 Linux User s Manual Managing Communication with algorithms are available type openvpn show ciphers openvpn show auths 4 Start both of OpenVPN peers openvpn config A tap0 br conf amp openvpn config B tap0 br conf amp If you see the line Peer Connection Initiated with 192 168 8 173 5000 on each machine the connection between OpenVPN machines has been established successfully on UDP port 5000 5 On each OpenVPN machine check the routing table by typing the command route Destination Gateway Genmsk Flags Metric Ref Use Iface 192 168 4 0 Bi 255 255 255 0 U 0 0 0 brO 192 168 2 0 u 255 255 255 0 U 0 0 0 brO 192 168 8 0 xX 255 255 255 0 U 0 0 0 eth0 Interface ethl is connected to the bridging interface br0 to which device tap0 also connects whereas the virtual device tun sits on top of tap0 This ensures that all traffic from internal networks connected to interface eth1 that come to this bridge write to the TAP TUN device that the OpenVPN program monitors Once the OpenVPN program detects traffic on the virtual device it sends the traffic to its peer 6 To create an indirect connection to Host B from Host A you need to
106. ping to test the IP 10 If you want to disconnect it use the kill command to kill the pppd process 4 18 1A240 241 Linux User s Manual Managing Communication NFS Network File System NOTE The Network File System NFS is used to mount a disk partition on a remote machine as if it were on a local hard drive allowing fast seamless sharing of files across a network NFS allows users to develop applications for the A240 241 without worrying about the amount of disk space that will be available The IA240 241 supports NFS protocol for client Click on the following links for more information about NFS http www tldp ors HOWTO NFS HOWTO index html http nfs sourceforge net nfs howto client html http nfs sourceforge net nfs howto server html Setting up the IA240 241 as an NFS Client Mail NOTE The following procedure is used to mount a remote NFS Server 1 To know the NFS Server s shared directory 2 Establish a mount point on the NFS Client site 3 Mount the remote directory to a local directory mkdir p home nfs public mount t nfs NFS Server IP directory mount point Example mount t nfs 192 168 3 100 home public home nfs public smtpclient is a minimal SMTP client that takes an email message body and passes it on to an SMTP server It is suitable for applications that use email to send alert messages or important logs to a specific user Click on the following link for m
107. printf Please select a choice gt scanf d amp nChoice if nChoice 9 Quit break elseif nChoice 0 test for din duration for nDuration 0 nDuration lt DURATION NUM nDuration configure the dout frequency When the timer timeouts dout_control will be called to change the dout state value it value tv sec duration 0 nDuration 1000 value it value tv usec duration 0 nDuration 1000 1000 value it_interval value it_value setitimer ITIMER_REAL amp value NULL r ndin_StateChangeDetected 0 reset these counters ndout_StateChangeDetected 0 printf DI duration 0 DO duration d n duration 0 nDuration set_din_event 0 low2highevent DIN_EVENT_LOW_TO_HIGH 0 while ndin_StateChangeDetected lt TEST_NUM pause printf ndin_StateChangeDetected d ndout_StateChangeDetected d n ndin_StateChangeDetected ndout_StateChangeDetected printf loss detection probability f n ndout_StateChangeDetected ndin_StateChangeDetected 100 0 nd out_StateChangeDetected end of if nChoice 0 elseif nChoice 1 test for din duration 0 for nDuration 0 nDuration lt DURATION NUM nDuration configure the dout frequence when the timer timeout dout_control will be call to change the dout state value it_value tv_sec duration 1 nDuration 1000 value it_value tv_usec duration 1 nDuration
108. r Installing the Tool Chain Linux NOTE The Linux Operating System must be pre installed in the PC before installing the A240 241 GNU Tool Chain Fedora core or compatible versions are recommended The Tool Chain requires approximately 100 MB of hard disk space on your PC The IA240 241 Tool Chain software is located on the IA240 241 CD To install the Tool Chain insert the CD into your PC and then issue the following commands mount dev cdrom mnt cdrom sh mnt cdrom tool chain linux install sh The Tool Chain will be installed automatically on your Linux PC within a few minutes Before compiling the program be sure to set the following path first since the Tool Chain files including the compiler link library and include files are located in this directory PATH usr local arm linux bin PATH Setting the path allows you to run the compiler from any directory Refer to Appendix B for an introduction to the Windows Tool Chain In this chapter we use the Linux tool chain to illustrate the cross compiling process 2 12 1A240 241 Linux User s Manual Getting Started Checking the Flash Memory Space If the flash memory is full you will not be able to save data to the Flash ROM Use the following command to calculate the amount of Available flash memory gt df h EN PComm Terminal Emulator COM1 115200 None 8 1 T100 Profile Edit PortManager Window Help a WA e ltajsjer Si2e E COM1 115200
109. r 1025 tepConnLocalPort 192 168 4 127 1025 0 0 0 0 0 integer 1025 tepConnLocalPort 192 168 27 139 2049 0 0 0 0 0 integer 2049 tepConnLocalPort 192 168 4 127 2049 0 0 0 0 0 integer 2049 tepConnLocalPort 192 168 27 139 1026 0 0 0 0 0 integer 1026 tepConnLocalPort 192 168 4 127 1026 0 0 0 0 0 integer 1026 tepConnLocalPort 192 168 27 139 9 0 0 0 0 0 integer 9 tepConnLocalPort 192 168 4 127 9 0 0 0 0 0 integer 9 tepConnLocalPort 192 168 27 139 111 0 0 0 0 0 integer 111 tepConnLocalPort 192 168 4 127 111 0 0 0 0 0 integer 111 tepConnLocalPort 192 168 27 139 80 0 0 0 0 0 integer 80 tepConnLocalPort 192 168 4 127 80 0 0 0 0 0 integer 80 tepConnLocalPort 192 168 27 139 21 0 0 0 0 0 integer 21 tepConnLocalPort 192 168 4 127 21 0 0 0 0 0 integer 21 tepConnLocalPort 192 168 27 139 22 0 0 0 0 0 integer 22 tepConnLocalPort 192 168 4 127 22 0 0 0 0 0 integer 22 tepConnLocalPort 192 168 27 139 23 0 0 0 0 0 integer 23 tepConnLocalPort 192 168 4 127 23 0 0 0 0 0 integer 23 tcpConnRemAddress 192 168 27 139 1024 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 1024 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 1025 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 1025 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 2049 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 2049 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 1026 0 0 0 0 0 ipadd
110. r serverS99showreadyled S20snmpd SoS S hl S24pcmcia SO99rmnologin root Moxa ect rc d rc3 d In s root tcps2 release S60tcps2 root Moxa ect rc d rc3 d ls S19nfs common S25nfs user serverS99rmnologin S20snmpd s55ssh S99showreadyled S24pcmcia Sevtcps2 root Moxa etc rce d rc3 d KxxRUNFILE stands for K start the run file while linux shuts down or halts xx a number between 00 99 Smaller numbers have a higher priority RUNFILE the file name To remove the daemon remove the run file from the etc re d re3 d directory by using the following command rm f etc rc d rc3 d S60tcps2 Adjusting the System Time Setting the Time Manually The IA240 241 has two time settings One is the system time and the other is the RTC Real Time Clock time kept by the IA240 241 s hardware Use the date command to query the current system time or set a new system time Use hwclock to query the current RTC time or set a new RTC time Use the following command to query the system time date Use the following command to query the RTC time hwclock Use the following command to set the system time date MMDDhhmmYYYY MM Month DD Date hhmm hour and minute YYYY Year Use the following command to set the RTC time hwclock w Write current system time to RTC The following figure illustrates how to update thesystem time and set the RTC time 3 8 1A240 241 Linux User s Manual Managing Embedded Linux
111. ram to be debugged follows these parameters For a program requiring arguments add the arguments behind the program name In the host computer change the directory to where the program source resides cd my_work_directory myfilesystem testprograms Execute the client program ddd debugger arm linux gdb hello debug amp Enter the following command at the GDB DDD command prompt Target remote 192 168 4 99 2000 The command produces a line of output on the target console similar to the following Remote debugging using 192 168 4 99 2000 192 168 4 99 is the machine s IP address and 2000 is the port number You can now begin debugging in the host environment using the interface provided by DDD Set a break point on main by double clicking or by entering b main on the command line Click the cont button 5 3 1A240 241 Linux User s Manual Development Tool Chains Windows Tool Chain The Windows tool chain is a cross development environment that simulates the Linux root file system allowing users to develop applications in a Windows PC environment The following figure shows an example of what the tool chain looks like Your group is currently mkpasswd This indicates that The etc passwd and possibly etc group files should be rebuil See the man pages for mkpasswd and mkgroup then for example ru mkpasswd 1 d gt etc passwd mkpasswd 1 d gt etc group Note that the d switch is necessary for
112. re file which can be downloaded from Moxa s website www moxa com The name of the file has the form ia240 x x x frm or ia241 x x x frm with x x x indicating the firmware version To upgrade the firmware download the firmware file to a PC and then transfer the file to the IA240 241 via a serial Console or Telnet Console connection Upgrading the firmware will erase all data on the Flash ROM If you are using the ramdisk to store code for your applications beware that updating the firmware will erase all of the data on the Flash ROM You should back up your application files and data before updating the firmware Since different Flash disks have different sizes it s a good idea to check the size of your Flash disk before upgrading the firmware or before using the disk to store your application and data files Use the a h command to list the size of each memory block and how much free space is available in each block 3 2 1A240 241 Linux User s Manual Managing Embedded Linux root Moxa df h Filesystem Size Used Available Use Mounted on dev mtdblock2 8 0M 6 0M 2 0M 75s X dev ram0 499 0k e MORK 458 0k 3 var dev mtdblock3 6 0M 488 0k 5 5M 8 tmp dev mtdblock3 6 0M 488 0k 5 5M 8 home dev mtdblock3 6 0M 488 0k 5 5M 8 etc tmpfs 30 4M 0 30 4M 0 dev shm root Moxa upramdisk root Moxa df h Filesystem Size Used Available Use Mounted on dev mtdblock2 8 0M 6 0M 2 0M Uses U dev ram0 499 0
113. ress 0 0 0 0 tcpConnRemAddress 192 168 4 127 1026 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 9 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 9 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 111 0 0 0 0 0 ipaddress 0 0 0 0 tepConnRemAddress 192 168 4 127 111 0 0 0 0 0 ipaddress 0 0 0 0 tepConnRemAddress 192 168 27 139 80 0 0 0 0 0 ipaddress 0 0 0 0 tepConnRemAddress 192 168 4 127 80 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 21 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 21 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 22 0 0 0 0 0 ipaddress 0 0 0 0 4 24 1A240 241 Linux User s Manual Managing Communication 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 331 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 tcpConnRemAddress 192 168 4 127 22 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 27 139 23 0 0 0 0 0 ipaddress 0 0 0 0 tcpConnRemAddress 192 168 4 127 23 0 0 0 0 0 ipaddress 0 0 0 0 tepConnRemPort 192 168 27 139 1024 0 0 0 0 0 integer 0 tcpConnRemPort 192 168 4 127 1024 0 0 0 0 0 integer 0 tcpConnRemPort
114. rst Application We use the tcps2 example to illustrate how to build an application The procedure outlined in the following subsections will show you how to build a TCP server program plus serial port communication that runs on the IA240 241 Testing Environment The tcps2 example demonstrates a simple application program that delivers transparent bi directional data transmission between the IA240 241 s serial and Ethernet ports As illustrated in the following figure the purpose of this application is to transfer data between PC 1 and the IA240 241 via an RS 232 connection At the remote site data can be transferred between the 1A240 241 s Ethernet port and PC 2 over an Ethernet connection 2 14 1A240 241 Linux User s Manual Getting Started PC 1 tcps2 c gt Serial Rx Buffer LAN Rx Buffer lt d Compiling tcps2 c The source code for the tcps2 example is located on the CD ROM at CD ROM example TCPServer2 tcps2 c Use the following commands to copy the file to a specific directory on your PC We use the direrctory home ia240241 1st_application Note that you need to copy 3 files Makefile tcps2 c tepsp c from the CD ROM to the target directory mount t iso9660 dev cdrom mnt cdrom cp mnt cdrom example TCPServer2 tcps2 c home ia240241 1st_application tcps2 c cp mnt cdrom example TCPServer2 tcpsp c home ia240241 1st_application tcpsp c cp mnt cdrom example TCPServer2 Makefile c home
115. rt 192 168 27 139 854 integer 854 udpLocalPort 192 168 4 127 854 integer 854 udpLocalPort 192 168 27 139 111 integer 111 udpLocalPort 192 168 4 127 111 integer 111 rs232Number 0 integer 4 rs232PortIndex 1 integer 1 1 4 25 1A240 241 Linux User s Manual Managing Communication 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 rs232PortIndex 2 integer 2 2 rs232PortIndex 3 integer 3 3 rs232PortIndex 4 integer 4 4 rs232PortType l integer rs232 2 rs232PortType 2 integer rs232 2 rs232PortType 3 integer rs232 2 rs232PortType 4 integer rs232 2 rs232PortInSigNumber 1 integer 3 rs232PortInSigNumber 2 integer 3 rs232PortInSigNumber 3 integer 3 rs232PortInSigNumber 4 integer 3 rs232PortOutSigNumber 1 integer 2 rs232PortOutSigNumber 2 integer 2 rs232PortOutSigNumber 3 integer 2 rs232PortOutSigNumber 4 integer 2 rs232PortInSpeed 1 integer 38400 rs232PortInSpeed 2 integer 38400 rs232PortInSpeed 3 integer 38400 rs232PortInSpeed 4 integer 38400 rs232PortOutSpeed 1 integer 38400 rs232PortOutSpeed 2 integer 38400 rs232PortOutSpeed 3 integer
116. sed by one program at a time Example Example 1 File Name tdio c Description The program indicates to connect DOI to DI change the digital output state to high or low by manual input then the detect and count the state changed events from DI1 OK include lt stdio h gt include lt stdlib h gt include lt moxadevice h gt include lt fentl h gt ifdef DEBUG define dbg printf x printf x else define dbg_printf x endif 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 number of menu other key to exit n 1 set high to low event n 2 get now data n 3 set low to high event n 4 clear event n 5 set high data n 6 set low data n 7 quit n 8 show event and duration n Choose retval 0 scanf d amp i if i 1 set high to low event printf Please keyin the DIN number scanf d amp i printf Please input the DIN duration this minimun value must be over d MIN_DURATION scanf Slu amp duration retval set_din_event i hightolowevent DIN_EVENT_HIGH_T
117. sleep 100000 DIO Program Make File Example FNAME tdio FNAME1 tduration CC arm linux gec STRIP arm linux strip release CC o FNAME FNAME c lmoxalib Ipthread CC o FNAME1 FNAMEl c lmoxalib lpthread STRIP s FNAME STRIP s FNAME1 debug CC DDEBUG o FNAME dbg FNAME cxx lmoxalib lpthread CC DDEBUG o FNAME1 dbg FNAME1 cxx lmoxalib Ipthread clean bin rm f FNAME FNAME dbg FNAME1 FNAMEl dbg o 6 14 1A240 241 Linux User s Manual Programmer s Guide Make File Example The following Makefile file example codes are copied from the Hello example on the IA240 241 s CD ROM cc usr local arm linux bin arm linux gcec CPP usr local arm linux bin arm linux gce SOURCES hello c OBJS SOURCES c o all hello hello OBJS CC o LDFLAGS LIBS clean rm f OBJS hello core gdb 6 15 7 Software Lock Software Lock is an innovative technology developed by the Moxa engineering force It can be adopted by a system integrator or developer to protect his applications from being copied An applicaion is compiled into a binary format bound to the embedded computer and the operating system OS that the application runs on As long as one obtains it from the computer he she can install it into the same hardware and the same operating system The add on value created by the developer is thus lost Moxa en
118. t in the home nat sh Remember to chmod 744 home nat sh Edit the rc local file to make this shell startup automatically vi etc rc d rc local Add a line in the end of rc local home nat sh EXIF ethO This is an external interface for setting up a valid IP address EXNET 192 168 4 0 24 This is an internal network address Step 1 Insert modules Here 2 gt dev null means the standard error messages will be dump to null device insmod ip_tables 2 gt dev null insmod ip_nat_ftp 2 gt dev null insmod ip_nat_irc 2 gt dev null insmod ip_conntrack 2 gt dev null insmod ip_conntrack_ftp 2 gt dev null insmod ip_conntrack_irc 2 gt dev null Step 2 Define variables enable routing and erase default rules PATH bin sbin usr bin usr sbin usr local bin usr local sbin export PATH echo 1 gt proc sys net ipv4 ip_forward bin iptables F bin iptables X bin iptables Z bin iptables F t nat bin iptables X t nat bin iptables Z t nat bin iptables P INPUT ACCEPT bin iptables P OUTPUT ACCEPT bin iptables P FORWARD ACCEPT bin iptables t nat P PREROUTING ACCEPT bin iptables t nat P POSTROUTING ACCEPT bin iptables t nat P OUTPUT ACCEPT Step 3 Enable IP masquerade Dial up Service PPP PPP Point to Point Protocol is used to run IP Internet Protocol and other network protocols over a serial link PPP can be used for direct serial connections using
119. tatus 3 integer down 2 ifOperStatus 4 integer down 2 ifOperStatus 5 integer down 2 ifOperStatus 6 integer down 2 ifLastChange 1 timeticks 0 days 00h 00m 00s 00th 0 4 20 1A240 241 Linux Us er s Manual Managing Communication 58 59 60 114 115 116 117 118 119 120 121 122 123 124 ifLastChange 2 timeticks 0 days 00h 00m 00s 00th 0 ifLastChange 3 timeticks 0 days 00h 00m 00s 00th 0 ifLastChange 4 timeticks 0 days 00h 00m 00s 00th 0 ifLastChange 5 timeticks 0 days 00h 00m 00s 00th 0 ifLastChange 6 timeticks 0 days 00h 00m 00s 00th 0 ifInOctets 1 counter 25511 ifInOctets 2 counter 2240203 ifInOctets 3 counter 0 ifInOctets 4 counter 0 ifInOctets 5 counter 0 ifInOctets 6 counter 0 ifInUcastPkts 1 counter 254 ifInUcastPkts 2 counter 28224 ifInUcastPkts 3 counter 0 ifInUcastPkts 4 counter 0 ifInUcastPkts 5 counter 0 ifInUcastPkts 6 counter 0 ifInNUcastPkts 1 counter 0 ifInNUcastPkts 2 counter 0 ifInNUcastPkts 3 counter 0 ifInNUcastPkts 4 counter 0 ifInNUcastPkts 5 counter 0 ifInNUcastPkts 6 counter 0 ifInDiscards 1 counter 0 ifInDiscards 2 counter 0 ifInDiscards 3 counter 0 ifInDiscards 4 counter 0 ifInDiscards 5 counter 0 ifInDiscards 6 counter 0 ifInErrors 1 counter 0 ifInErrors 2 counter 0 ifInErrors 3 counter 0
120. terface is used to develop applications with the tool chain To access the command line you need to launch a BASH shell window To open a BASH shell window choose Start Menu gt Programs gt UC Tool Chain gt Moxa Bash Shell or lick on the desktop Moxa Bash Shell icon 5 8 1A240 241 Linux User s Manual Development Tool Chains Your group is currently mkpasswd This indicates that The etc passwd and possibly etc group files should be rebuil See the man pages for mkpasswd and mkgroup then for example ru mkpasswd 1 d gt etc passwd mkpasswd 1 d gt etc group Note that the d switch is necessary for domain users S dhs Sel totar 9 drwxr xr x drwxr xr x drwxr xr x drwxr xr x E eeen drwxr xr x EWS xe x LW r r drwxr xr x Chap ieee drwxr xr x stephen_ mkpasswd Jan 10 24 stephen_ mkpasswd Jan 10 24 stephen_ mkpasswd Jan 10 48 bin stephen_ mkpasswd dank 24 etc stephen_ mkpasswd Jan 10 3 Insight co stephen_ mkpasswd Jan 10 19 48 lib stephen_ mkpasswd Sp icon AL AA cs Moreno stephen_ mkpasswd Jan 10 22203 moxa 1co stephen_ mkpasswd Jan 10 19 48 tmp stephen_ mkpasswd O Jan LO 19243 wer stephen_ mkpasswd O Jan 10 18 12 war pea Ds NEUE Noo 00 Son Compilation for Applications Windows tool chain is a cross compiler that can be used to compile Linux source code on a Windows operating system allowing programmers to develop projects on a Windows based PC In this section we
121. tion NOTE Click on the following links for more information about MIB II and RS 232 like groups http www fags org rfes rfc1213 html http www fags org rfes rfc1317 html gt 1A240 241 does NOT support SNMP trap OpenVPN OpenVPN provides two types of tunnels for users to implement VPNS Routed IP Tunnels and Bridged Ethernet Tunnels To begin with check to make sure that the system has a virtual device dev net tun If not issue the following command mknod dev net tun c 10 200 An Ethernet bridge is used to connect different Ethernet networks together The Ethernets are bundled into one bigger logical Ethernet Each Ethernet corresponds to one physical interface or port that is connected to the bridge On each OpenVPN machine you should generate a working directory such as etc openvpn where script files and key files reside Once established all operations will be performed in that directory Setup 1 Ethernet Bridging for Private Networks on Different Subnets 1 Set up four machines as shown in the following diagram local net OpenVPNA LANI 192 168 2 173 LANI 192 168 2 171 LAN2 192 168 8 173 Internet LANI 192 168 8 174 LANI 192 168 4 172 LAN2 192 168 4 174 OpenVPN B local net Host A B represents one of the machines that belongs to OpenVPN A B The two remote subnets are configured for a different range of IP addresses When this setup is mov
122. unter 0 ipReasmFails 0 counter 0 ipFragOKs 0 counter 0 ipFragFails 0 counter 0 ipFragCreates 0 counter 0 ipAdEntAddr 192 168 27 139 ipaddress 192 168 27 139 ipAdEntAddr 192 168 4 127 ipaddress 192 168 4 127 ipAdEntlfIndex 192 168 27 139 integer 1 ipAdEntIfIndex 192 168 4 127 integer 2 ipAdEntNetMask 192 168 27 139 ipaddress 255 255 255 0 ipAdEntNetMask 192 168 4 127 ipaddress 255 255 255 0 ipAdEntBcastAddr 192 168 27 139 integer 1 ipAdEntBcastAddr 192 168 4 127 integer 1 ipAdEntReasmMaxSize 192 168 27 139 integer 65535 ipAdEntReasmMaxSize 192 168 4 127 integer 65535 ipRouteDest 192 168 4 0 ipaddress 192 168 4 0 ipRouteDest 192 168 27 0 ipaddress 192 168 27 0 ipRoutelfIndex 192 168 4 0 integer 2 ipRoutelfIndex 192 168 27 0 integer 1 ipRouteMetric1 192 168 4 0 integer 0 ipRouteMetric1 192 168 27 0 integer 0 ipRouteMetric2 192 168 4 0 integer 1 ipRouteMetric2 192 168 27 0 integer 1 ipRouteMetric3 192 168 4 0 integer 1 ipRouteMetric3 192 168 27 0 integer 1 ipRouteMetric4 192 168 4 0 integer 1 ipRouteMetric4 192 168 27 0 integer 1 ipRouteNextHop 192 168 4 0 ipaddress 192 168 4 127 ipRouteNextHop 192 168 27 0 ipaddress 192 168 27 139 ipRouteType 192 168 4 0 integer direct 3 ipRouteType 192 168 27 0 integer direct 3 4 22 1A240 241 Linux User s Manual Managing Communication 192 193 194 195 196 197 198 199 200 201 202 203 204 205
123. utput OK will be zero 6 8 1A240 241 Linux User s Manual Programmer s Guide int set_din_event int diport void func int diport int mode long int duration Description Set the callback function for digital input port when the state is changed from high to low low to high or any sate changed Input int diport the digital output port number It is 0 to 3 void func int diport The call back function point It will be called when the set event happens intmode Setthe kind event High to low low to high or both long int duration We know the digital signal sometime is not reliable You can the duration time to except the error signal If you set to zero it will not detect the duration time You can set 40 ms to 3600000 ms by increase 20 ms Output OK will be zero Digital Input Signal DIN_EVENT_HIGH_TO_LOW Think ore 14241 E duration int get_din_event int diport int mode long int duration Description Get the set event for digital input port Input int diport the digital output port number It is 0 to 3 int mode Save the set event long int duration Save the set duration time value Output OK will be zero 6 9 1A240 241 Linux User s Manual Programmer s Guide Special Note Don t forget to link the library libmoxalib amp libpthread for DI DO programming and also include the header file moxadevice h The DI DO library only can be u
124. xample shell script to update the system time periodically 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 Save the shell script using any file name E g fixtime How to run the shell script automatically when the kernel boots up 3 9 1A240 241 Linux User s Manual Managing Embedded Linux Copy the example shell script fixtime to directory etc init d and then use chmod 755 fixtime to change the shell script mode Next use vi editor to edit the file etc inittab Add the following line to the bottom of the file ntp 2345 respawn etc init d fixtime Use the command init q to re init the kernel Cron Daemon to Execute Scheduled Commands Start Cron from the directory ete rc d rc local It will return immediately so you don t need to start it with amp to run in the background The Cron daemon will search etc cron d crontab for crontab files which are named after accounts in etc passwd Cron wakes up every minute and checks each command to see if it should be run in the current minute When executing commands output is mailed to the owner of the crontab or to the user named in the MAILTO enviro
Download Pdf Manuals
Related Search
Related Contents
User Manual of the DS-7108HI-S V7 Replacement Battery for selected Dell Notebooks Wet and Dry Face and Body Brush índice - ignitec - Grupo Giga (Vortex Flow) Controls - ESEP Milieutechniek BV GE 164D3333P034 Range User Manual Copyright © All rights reserved.
Failed to retrieve file