RS485 Module under console of Linux

From LEXWiKi

(Difference between revisions)
Jump to: navigation, search
(The Sample code source you can download from)
Current revision (14:09, 25 February 2022) (edit) (undo)
(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: [https://drive.google.com/file/d/1aMU0yxQKPmeo83qGEqstVWImEUX1amdX/view?usp=sharing RS485_Console_v1.1_Src]<br />
+
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
Line 8: Line 13:
$make
$make
$./rs485_console
$./rs485_console
-
Binary file: [https://drive.google.com/file/d/1hrGmBBHuniL69eK3A7K5I-PGNRCOk7ko/view?usp=sharing RS485_Console_v1.1_Bin]
+
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 ==

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);
Personal tools