請先看『使用說明』
RS485 Module under console of Linux
From LEXWiKi
(Difference between revisions)
(→The Sample code source you can download from) |
|||
Line 1: | Line 1: | ||
[[Category:AllowPages]] | [[Category:AllowPages]] | ||
== The Sample code source you can download from == | == The Sample code source you can download from == | ||
- | Source file: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/LCM_release/Linux_base/LCMctl_v2.2L_Src.tar.gz LCMctl_v2.2L_Src.tar.gz] | + | Source file: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/LCM_release/Linux_base/LCMctl_v2.2L_Src.tar.gz LCMctl_v2.2L_Src.tar.gz]<br /> |
Refer below steps to source code to binary file | Refer below steps to source code to binary file | ||
1.Using Code::Blocks to load project and build a binary file | 1.Using Code::Blocks to load project and build a binary file | ||
2.Using "make" command to compile source code and create it. | 2.Using "make" command to compile source code and create it. | ||
- | $cd | + | $cd /rs485_console_source/485_console |
$make | $make | ||
- | $./ | + | $./rs485_console |
Binary file: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/LCM_release/Linux_base/LCMctl_v2.2L_Bin.tar.gz LCMctl_v2.2L_Bin.tar.gz] | Binary file: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/LCM_release/Linux_base/LCMctl_v2.2L_Bin.tar.gz LCMctl_v2.2L_Bin.tar.gz] | ||
Revision as of 11:00, 7 July 2010
Contents |
The Sample code source you can download from
Source file: LCMctl_v2.2L_Src.tar.gz
Refer below steps to source code to binary file
1.Using Code::Blocks to load project and build a binary file 2.Using "make" command to compile source code and create it. $cd /rs485_console_source/485_console $make $./rs485_console
Binary file: LCMctl_v2.2L_Bin.tar.gz
How to use the application
1.assign the port is Send node or Receive node.
Please select Send or Receiver port(Send:1 , Recive:2)
2.choice open port number(default is port1~10)
Please input port number(1~10)
3.assign the por is RS485 or RS232
choose your port style: 1:RS485 2:RS232
4.If you assign RS485 style of COM port in previous choose , will be show this question.
In this question,If hardware autoflow control is opened , keyin Y or y.
Do you use hardware autoflow control for RS485 (Y/N)
Sample code Introduction
Open COM Port Device
default setting COM1~10,you can modify"/dev/ttyS0" to open other COM port device.
case 1: fd=open("/dev/ttyS0",O_RDWR| O_NOCTTY | O_NDELAY); break; case 2: fd=open("/dev/ttyS1",O_RDWR| O_NOCTTY | O_NDELAY); break; case 3: fd=open("/dev/ttyS2",O_RDWR| O_NOCTTY | O_NDELAY); break;
Control RTS signal
1.control RTS high to send data for COM port
ioctl(Port_fd, TIOCMGET, &mcs); mcs |= TIOCM_RTS; //RTS high ioctl(Port_fd, TIOCMSET, &mcs);
2.control RTS low to receive data for COM port
ioctl(Port_fd, TIOCMGET, &mcs); mcs &= ~TIOCM_RTS; //RTS low ioctl(Port_fd, TIOCMSET, &mcs);
Send Message
Send message and return transfer counts
write(Port_fd,o_char,i);
Receive Message
Receive message and return receive counts
read(Port_fd,i_char,1024);