0% found this document useful (0 votes)
5 views5 pages

DMT Library CSharp

The document outlines the DMT Library for C#, detailing the setup for Modbus Serial and TCP communication, including functions for opening and closing connections. It also describes data transmission methods for sending and receiving Modbus data, as well as error handling for both serial and socket connections. Each function includes parameters, descriptions, returned values, and remarks for proper implementation.

Uploaded by

Roberto Rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

DMT Library CSharp

The document outlines the DMT Library for C#, detailing the setup for Modbus Serial and TCP communication, including functions for opening and closing connections. It also describes data transmission methods for sending and receiving Modbus data, as well as error handling for both serial and socket connections. Each function includes parameters, descriptions, returned values, and remarks for proper implementation.

Uploaded by

Roberto Rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DMT Library(C#)

1. Setup Communication
-----------------------------------------------------------------------------------------
Modbus Serial
-----------------------------------------------------------------------------------------
OpenModbusSerial

Parameters
conn_num Serial port number, e.g. COM"1" (Support multiple
connections)
baud_rate Baud rate, e.g. 9600
data_len Data length, e.g. 7
parity Parity bit, e.g. 'E'
stop_bits Stop bit, e.g. 1
modbus_mode Modbus mode, 1:Modbus ASCII, 2:Modbus RTU

Description
Create a Modbus serial connection

Returned value
-1 Serial open failed
Non zero Serial open succeeded

Remarks
When setting up a modbus serial communication , the port number is a
"Connection ID number" as well,
this ID is used for indicating a specific serial port to send or receive data while
requesting or responding.
There are 32 simutaneous serial communications at most.
----------------------------------------------------------------------------------------------------------
CloseSerial
Description
Close the Modbus serial connection
-----------------------------------------------------------------------------------------------------------
Modbus TCP

OpenModbusTCPSocket
Parameters
conn_num Connection ID number (Support multiple connections )
ipaddr Modbus server's IP address

Description
Create a Modbus TCP socket connection

Returned value
-1 Socket open failed
Non zero Socket open succeeded

Remarks

CloseSocket
Description
Close the Modbus socket connection

2. Data Transmission
RequestData

Parameters
comm_type Communication type, 0:Serial, 1:Ethernet
conn_num Serial port number or Connection ID number
station_addr Station address
func_code Function code
data Modbus data
datalen Modbus data length (Buffer length)

Description
Send request for Modbus data

Returned Value
-1 Send data failed
Non zero The total number of bytes sent will be returned
---------------------------------------------------------------------------------------------
ResponseData

Parameters
comm_type Communication type, 0:Serial, 1:Ethernet
conn_num Serial port number or Connection ID number
station_addr Returned Station address
func_code Returned function code
data Returned Modbus data, If error occurring, the Modbus
Exception Code will returned

Description
Receive response from Modbus data

Returned Value
-1 Send data failed
Non zero The Modbus data byte count will be returned
--------------------------------------------------------------------------------------------
3. Error Message
-----------------------------------------------------------------------------------------
Modbus Serial
-----------------------------------------------------------------------------------------
GetLastSerialErr
Description
Acquire the last serial error message

Returned value
0 No serial error
1 Invalid serial error code
2 Invalid baud rate
3 Buffer overflow error
4 Invalid character size
5 Invalid flow control
6 Cannot initialize serial device
7 Invalid initialization parameter
8 Cannot open serial device
9 Invalid parity
10 Serial device receive error
11 Invalid stop bit
12 Serial device transmit error
------------------------------------------------------------------------------------------------------------
ResetSerialErr
Description
Reset the serial error message
-----------------------------------------------------------------------------------------
Modbus TCP
-----------------------------------------------------------------------------------------
GetLastSocketErr
Description
Acquire the last socket error message

Returned value
0 No socket error
1 Invalid socket error code
2 Accepting remote socket error
3 Socket cannot be bound
4 Buffer overflows
5 Socket cannot be connected
6 Socket has been disconnected
7 File length does not match the expected value
8 File modification time and dates do not match
9 A file system error occurs
10 Acquiring socket option error
11 Could not resolve hostname
12 Initialization error
13 Listen error
14 Acquiring peer name error
15 Unknown protocol requested
16 Receiving error
17 Request time-out
18 Unknown service requested
19 Incorrect socket option settings
20 Acquiring socket name error
21 Unknown socket type requested
22 Transmission error
--------------------------------------------------------------------------------------------
ReadSelect
Description
For determining the status of socket (millisecond)

Returned value
1 Data are ready
0 Date are not ready or socket error
--------------------------------------------------------------------------------------------
ResetSocketErr
Description
Reset the socket error message

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy