請先看『使用說明』
RS485 Module under console of Linux
From LEXWiKi
(New page: Category:AllowPages == 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 ...) |
(→The Sample code source you can download from) |
||
(7 intermediate revisions not shown.) | |||
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/ | + | Source file: |
+ | |||
+ | <Google Drive> [https://drive.google.com/file/d/1aMU0yxQKPmeo83qGEqstVWImEUX1amdX/view?usp=sharing RS485_Console_v1.1_Src] | ||
+ | |||
+ | <FTP> [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/RS485/rs485_console_source.tar.gz RS485_Console_v1.1_Src] | ||
+ | |||
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/ | + | Binary file: |
+ | |||
+ | <Google Drive> [https://drive.google.com/file/d/1hrGmBBHuniL69eK3A7K5I-PGNRCOk7ko/view?usp=sharing RS485_Console_v1.1_Bin] | ||
+ | |||
+ | <FTP> [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/RS485/rs485_console_source1.1.tar.gz RS485_Console_v1.1_Bin] | ||
== How to use the application == | == How to use the application == | ||
Line 20: | Line 29: | ||
2:RS232 | 2:RS232 | ||
4.If you assign RS485 style of COM port in previous choose , will be show this question.<br /> | 4.If you assign RS485 style of COM port in previous choose , will be show this question.<br /> | ||
- | In this question,If | + | In this question,If software control is opened , keyin 1:enable. |
- | + | Enable or disable your RTS (1:enable/2:disable) | |
+ | |||
+ | == 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); |
Current revision
Contents |
The Sample code source you can download from
Source file:
<Google Drive> RS485_Console_v1.1_Src
<FTP> RS485_Console_v1.1_Src
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:
<Google Drive> RS485_Console_v1.1_Bin
<FTP> RS485_Console_v1.1_Bin
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 software control is opened , keyin 1:enable.
Enable or disable your RTS (1:enable/2:disable)
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);