Moxa IA3341-LX [61/72] Function moxa_set_op_mode
![Moxa IA3341-LX [61/72] Function moxa_set_op_mode](/views2/1200029/page61/bg3d.png)
IA3341 Linux User’s Manual Programmer’s Guide
6-6
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 < 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
UART
The normal tty device node is located at
/dev/ttyM0 … ttyM3
.
The IA3341 supports Linux standard termial control. The Moxa UART Device API allows you to
configure ttyM0 to ttyM3 as RS-232, RS-422, 4-wire RS-485, or 2-wire RS-485. IA3341 supports
RS-232, RS-422, 2-wire RS-485, and 4-wire RS-485.
You must
include <moxadevice.h>
.
#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, &mode)
Description
Set the interface mode. Argument 3 mode will pass to the UART device driver and change it.
Содержание
- First edition may 2010 1
- Ia3341 linux user s manual 1
- Www moxa com product 1
- Copyright notice 2
- Disclaimer 2
- Ia3341 linux user s manual 2
- Technical support contact information www moxa com support 2
- Trademarks 2
- Table of contents 3
- Chapter 1 introduction 5
- Introduction 5
- Overview 6
- Software architecture 6
- Journaling flash file system jffs2 7
- Software specifications 8
- Chapter 2 getting started 9
- Getting started 9
- Connecting the ia3341 to a pc 10
- Powering on the ia3341 10
- Serial console 10
- Ssh console 11
- Windows users 11
- Configuring the ethernet interface 12
- Linux users 12
- Modifying network settings with the serial console 13
- Modifying network settings over the network 14
- Sd socket and usb for storage expansion 14
- Test program developing hello c 14
- Checking the flash memory space 15
- Installing the tool chain linux 15
- Compiling hello c 16
- Uploading and running the hello program 16
- Compiling tcps2 c 17
- Developing your first application 17
- Ia3341 17
- Pc1 pc2 17
- Rs 232 lan 17
- Testing environment 17
- Uploading and running the tcps2 release program 18
- 11 2 11 19
- Command to check if the tcps2 program is actually running in the background 19
- From the ia3341 type 19
- Ia3341 linux user s manual getting started 19
- The program should start running in the background use the 19
- Summary of the testing procedure 20
- Chapter 3 managing embedded linux 21
- Managing embedded linux 21
- System image backup 22
- System version information 22
- Upgrading the firmware 22
- Ia3341 linux user s manual managing embedded linux 23
- The following instructions give the steps required to save the firmware file to the ia3341 s ram disk and how to upgrade the firmware 23
- Type the following commands to enable the ram disk 23
- Type the following commands to use the ia3341 s built in ftp client to transfer the firmware file ia3341 x x frm from the pc to the ia3341 23
- Loading factory defaults 24
- Backing up the user directory 25
- 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 25
- Deploying the user directory to additional ia3341 units 25
- For some applications you may need to ghost one ia3341 user file system to other ia3341 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 ia3341 units 25
- Ia3341 linux user s manual managing embedded linux 25
- Once the file system is backed up use ftp to transfer the file usrfs backup to your pc 25
- Upramdisk cd mnt ramdisk upfirm usrfs backup 25
- Cd etc rc d vi rc local 26
- Enabling and disabling daemons 26
- Ia3341 linux user s manual managing embedded linux 26
- Inetd internet daemons ftpd ftp server client daemon sshd secure shell server daemon mbat modbus daemon 26
- Next use vi to open your application program we use the example program tcps2 release and set it to run in the background 26
- Starting a program automatically at run level 26
- The following daemons are enabled when the ia3341 boots up for the first time 26
- To set a private daemon to run at run level you can edit the file rc local as follows 26
- Type the command ps ef to list all processes currently running 26
- Cd etc rc d init d 27
- Cd etc rc d rc3 d ln s etc rc d init d tcps2 s60tcps2 27
- Edit a shell script to execute root tcps2 release and save to tcps2 as an example 27
- Ia3341 linux user s manual managing embedded linux 27
- 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 27
- Setting the run level 27
- Sxxrunfile stands for s start the run file while linux boots up xx a number between 00 99 the smaller number has a higher priority runfile the file name 27
- You will find that the following daemons are enabled after you reboot the system 27
- Adjusting the system time 28
- Ntp client 28
- Setting the time manually 28
- Cron daemon to execute scheduled commands 29
- Updating the time automatically 29
- Chapter 4 managing communications 31
- Managing communications 31
- Web service apache 32
- Ia3341 linux user s manual managing communications 34
- Install php for apache web server 34
- Note 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 file is executable 34
- Step 1 check that you have enough free space the following figure illustrates how to check that the dev mtdblock3 has more than 3 mb of free space 34
- Step 2 type upramdisk to get the free space ram disk to save the package 34
- 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 34
- Ia3341 linux user s manual managing communications 35
- Step 3 download the php package from the cd rom you can find the package in cd rom target php php tgz 35
- Step 4 untar the package to do this type the command tar xvzf php tgz 35
- Iptables 36
- Define policy for chain rules 39
- Observe and erase chain rules 39
- Append or delete rules 40
- Nat area private ip 41
- Nat example 41
- 12 4 12 42
- Dial up service ppp 42
- Enabling nat at bootup 42
- Ia3341 linux user s manual managing communications 42
- In most real world situations you will want to use a simple shell script to enable nat when the ia3341 boots up the following script is an example 42
- Modem ppp access is almost identical to connecting directly to a network through the ia3341 s ethernet port since ppp is a peer to peer system the ia3341 can also use ppp to link two networks or a local network to the internet to create a wide area network wan 42
- 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 42
- 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 a null modem cable over a telnet link and links established using a modem over a telephone line 42
- The pppd daemon is used to connect to a ppp server from a linux system for detailed information about pppd see the man page 42
- Example 1 connecting to a ppp server over a simple dial up connection 43
- Example 2 connecting to a ppp server over a hard wired link 44
- How to check the connection 44
- Setting up a machine for incoming ppp connections 45
- Nfs network file system 47
- Setting up the ia3341 as an nfs client 48
- Installing net snmp 49
- 20 4 20 50
- Ia3341 linux user s manual managing communications 50
- Step 4 type command tar xvzf net snmp tgz to untar the package 50
- Step 5 run install sh and select to install the snmp daemon 50
- 21 4 21 51
- Ia3341 linux user s manual managing communications 51
- Step 6 run the command snmpd c etc snmpd snmpd conf to wake up snmp daemon 51
- Step 7 use snmp client to query from target for testing 51
- The following simple example allows you to use an snmpwalk program on the host site to query the ia3341 which is the snmp agent the ia3341 will respond 51
- Uage like snmpwalk v 1 c public target ip 51
- 22 4 22 52
- Ia3341 linux user s manual managing communications 52
- Note click on the following links for more information about mib ii and rs 232 like groups http www faqs org rfcs rfc1213 html http www faqs org rfcs rfc1317 html the ia3341 does not support snmp trap 52
- Chapter 5 development tool chains 53
- Development tool chains 53
- Compilation for applications 54
- Linux tool chain 54
- Steps for installing the linux tool chain 54
- On line debugging with gdb 55
- Chapter 6 programmer s guide 56
- Programmer s guide 56
- Before programming your embedded system 57
- Caution required when using file systems 57
- Device api 57
- Flash memory map 57
- Using a ram file system instead of a flash file system 57
- Buzzer 58
- Rtc real time clock 58
- Wdt watch dog timer 58
- Example 1 60
- Example 2 60
- Ia3341 linux user s manual programmer s guide 60
- Special note 60
- The makefile is shown below 60
- User application example 60
- When you kill the application with 9 or kill without option or ctrl c the kernel will change to auto ack the swatchdog 60
- 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 60
- Description set the interface mode argument 3 mode will pass to the uart device driver and change it 61
- Function moxa_set_op_mode 61
- Ia3341 linux user s manual programmer s guide 61
- Include moxadevice h 61
- The ia3341 supports linux standard termial control the moxa uart device api allows you to configure ttym0 to ttym3 as rs 232 rs 422 4 wire rs 485 or 2 wire rs 485 ia3341 supports rs 232 rs 422 2 wire rs 485 and 4 wire rs 485 61
- The makefile is shown below 61
- The normal tty device node is located at 61
- You must 61
- Baudrate error 62
- Example to get the baudrate 62
- Example to set the baudrate 62
- Special note 62
- Application programming interface 63
- Digital i o 63
- 1 from high to low 65
- 10 6 10 65
- 3600000 milliseconds 65
- Description the program indicates to connect do1 to di1 change the digital output state to high or low by manual input then detect and count the state changed events from di1 65
- Din_event_clear 1 clear this event 65
- Din_event_low_to_high 0 from low to high 65
- Dio program source code file example 65
- Don t forget to link the library libmoxalib for di do programming and also include the header file moxadevice h the di do library only can be used by one program at a time 65
- Duration the value of duration should be 0 or 40 duration 65
- Examples 65
- File name tdio c 65
- Ia3341 linux user s manual programmer s guide 65
- Output mode din_event_high_to_low 65
- Return reference the error code 65
- Return to the current duration value of diport 65
- Special note 65
- Unsigned long duration the duration of the din port is kept in high or low state 65
- 11 6 11 66
- Ia3341 linux user s manual programmer s guide 66
- 12 6 12 67
- Ia3341 linux user s manual programmer s guide 67
- Modbus 68
Похожие устройства
- Moxa IA3341-LX Технические характеристики
- Moxa IA3341-LX Руководство по аппаратной части
- Moxa IA3341-LX Руководство по быстрой установке
- Moxa IA3341-LX Руководство по работе с утилитой Moxa Device Manager
- Moxa V2406A-C2 Инструкция по эксплуатации
- Moxa V2406A-C2 Технические характеристики
- Moxa V2406A-C2 Руководство по аппаратной части
- Moxa V2406A-C2 Руководство по быстрой установке
- Moxa V2406A-C2-T Инструкция по эксплуатации
- Moxa V2406A-C2-T Руководство по аппаратной части
- Moxa V2406A-C2-T Технические характеристики
- Moxa V2406A-C2-T Руководство по быстрой установке
- Moxa V2406A-C2-W7E Инструкция по эксплуатации
- Moxa V2406A-C2-W7E Руководство по аппаратной части
- Moxa V2406A-C2-W7E Технические характеристики
- Moxa V2406A-C2-W7E Руководство по быстрой установке
- Moxa V2406A-C2-T-W7E Инструкция по эксплуатации
- Moxa V2406A-C2-T-W7E Руководство по аппаратной части
- Moxa V2406A-C2-T-W7E Технические характеристики
- Moxa V2406A-C2-T-W7E Руководство по быстрой установке