LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-11-2010, 07:28 AM   #1
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Rep: Reputation: 18
MODBUS/TCP to MODBUS/RTU gateway server problem on PC


hello
I download modbus gateway from (http://mbus.sourceforge.net/) and compiled it for both my PC with:
Quote:
[root@localhost FORPC]# uname -a
Linux localhost.localdomain 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 athlon i386 GNU/Linux
and my embedded computer with:
Quote:
root@Moxa:/mnt/sd/Utility# uname -a
Linux Moxa 2.6.9-uc0 #279 Wed Oct 3 19:46:41 CST 2007 armv4tl unknown
it work very well for embedded computer with a few problem that they are nothing but it has problem with my pc when I use the same command as my embedded computer on my pc it put this error out:
Quote:
[root@localhost FORPC]# mbusd -d -v 2 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271074098:815970 mbusd-0.1.2 started...
1271074098:817335 tty: error in read() (Input/output error)
1271074098:817610 mbusd-0.1.2 exited...
my serial port information with the following commands are:
Quote:
[root@localhost FORPC]# setserial -ag /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test

[root@localhost FORPC]# stty
speed 19200 baud; line = 0;
-brkint -imaxbel iutf8
I have to say that I checked all the physical connections and I know that there is no problem with them.
another useful information that I can tell is when I unplug the serial cable it seems that make a connection but still has problem for reading the data I don't know where but this is the full information of what happening:
the ModBus Gatway side:
Quote:
[root@localhost FORPC]# mbusd -d -v 2 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271074483:416362 mbusd-0.1.2 started...
1271074530:913703 conn_open(): accepting connection from 192.168.8.204
1271074559:765040 conn_open(): accepting connection from 192.168.8.204
1271074559:765193 conn_close(): closing connection from 192.168.8.204
1271074598:229893 conn_open(): accepting connection from 192.168.8.204
1271074598:230044 conn_close(): closing connection from 192.168.8.204
1271074636:693930 conn_open(): accepting connection from 192.168.8.204
1271074636:694081 conn_close(): closing connection from 192.168.8.204
1271074675:159348 conn_open(): accepting connection from 192.168.8.204
1271074675:159505 conn_close(): closing connection from 192.168.8.204
1271074687:019573 conn_close(): closing connection from 192.168.8.204
1271074694:364985 Terminated by signal: SIGINT
this is the output of modbus 9th level logging with the same situation:
Quote:
[root@localhost FORPC]# mbusd -d -v 9 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271075073:704300 mbusd-0.1.2 started...
1271075073:704903 tty: state now is TTY_READY
1271075073:705192 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075073:705447 tty: error in read() (Input/output error)
1271075073:705658 mbusd-0.1.2 exited...
[root@localhost sms]# mbusd -d -v 9 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271075080:629698 mbusd-0.1.2 started...
1271075080:630273 tty: state now is TTY_READY
1271075080:630544 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075084:241146 tty: error in read() (Success)
1271075084:241290 mbusd-0.1.2 exited...
[root@localhost sms]# mbusd -d -v 9 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271075089:550685 mbusd-0.1.2 started...
1271075089:551270 tty: state now is TTY_READY
1271075089:551557 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075090:837590 tty: error in read() (Success)
1271075090:837710 mbusd-0.1.2 exited...
[root@localhost sms]# mbusd -d -v 9 -p /dev/ttyS0 -W 50 -N 10 -T 10 -s 19200
1271075093:311985 mbusd-0.1.2 started...
1271075093:312564 tty: state now is TTY_READY
1271075093:312864 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075103:312810 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075104:674760 conn_open(): accepting connection from 192.168.8.204
1271075104:674906 queue_new_elem(): length now is 1
1271075104:674961 conn[192.168.8.204]: state now is CONN_HEADER
1271075104:675014 conn_loop(): select(): max_sd = 6, t_out = 000010:000000
1271075107:674891 conn[192.168.8.204]: state now is CONN_RQST
1271075107:675035 conn[192.168.8.204]: state now is CONN_TTY
1271075107:675090 tty: state now is TTY_RQST
1271075107:676187 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:676279 tty: written 8 bytes
1271075107:676330 tty: request written (total 8 bytes)
1271075107:676379 tty: state now is TTY_RESP
1271075107:676429 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075107:730803 tty: response timeout
1271075107:730946 tty: attempt to retry request (1 of 10)
1271075107:730997 tty: state now is TTY_RQST
1271075107:732092 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:732180 tty: written 8 bytes
1271075107:732228 tty: request written (total 8 bytes)
1271075107:732276 tty: state now is TTY_RESP
1271075107:732328 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075107:786809 tty: response timeout
1271075107:786955 tty: attempt to retry request (2 of 10)
1271075107:787006 tty: state now is TTY_RQST
1271075107:788103 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:788191 tty: written 8 bytes
1271075107:788239 tty: request written (total 8 bytes)
1271075107:788287 tty: state now is TTY_RESP
1271075107:788338 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075107:842814 tty: response timeout
1271075107:842961 tty: attempt to retry request (3 of 10)
1271075107:843020 tty: state now is TTY_RQST
1271075107:844116 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:844185 tty: written 8 bytes
1271075107:844253 tty: request written (total 8 bytes)
1271075107:844304 tty: state now is TTY_RESP
1271075107:844355 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075107:898811 tty: response timeout
1271075107:899159 tty: attempt to retry request (4 of 10)
1271075107:899383 tty: state now is TTY_RQST
1271075107:900644 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:900951 tty: written 8 bytes
1271075107:901160 tty: request written (total 8 bytes)
1271075107:901373 tty: state now is TTY_RESP
1271075107:901584 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075107:956819 tty: response timeout
1271075107:956986 tty: attempt to retry request (5 of 10)
1271075107:957039 tty: state now is TTY_RQST
1271075107:958136 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075107:958203 tty: written 8 bytes
1271075107:958273 tty: request written (total 8 bytes)
1271075107:958321 tty: state now is TTY_RESP
1271075107:958373 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:012809 tty: response timeout
1271075108:012952 tty: attempt to retry request (6 of 10)
1271075108:013003 tty: state now is TTY_RQST
1271075108:014099 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075108:014166 tty: written 8 bytes
1271075108:014234 tty: request written (total 8 bytes)
1271075108:014284 tty: state now is TTY_RESP
1271075108:014335 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:068817 tty: response timeout
1271075108:068964 tty: attempt to retry request (7 of 10)
1271075108:069016 tty: state now is TTY_RQST
1271075108:070114 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075108:070203 tty: written 8 bytes
1271075108:070251 tty: request written (total 8 bytes)
1271075108:070299 tty: state now is TTY_RESP
1271075108:070350 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:124811 tty: response timeout
1271075108:125150 tty: attempt to retry request (8 of 10)
1271075108:125247 tty: state now is TTY_RQST
1271075108:126341 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075108:126422 tty: written 8 bytes
1271075108:126463 tty: request written (total 8 bytes)
1271075108:126506 tty: state now is TTY_RESP
1271075108:126549 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:180866 tty: response timeout
1271075108:181216 tty: attempt to retry request (9 of 10)
1271075108:181429 tty: state now is TTY_RQST
1271075108:182679 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075108:182942 tty: written 8 bytes
1271075108:183141 tty: request written (total 8 bytes)
1271075108:183349 tty: state now is TTY_RESP
1271075108:183552 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:237813 tty: response timeout
1271075108:237957 tty: attempt to retry request (10 of 10)
1271075108:237999 tty: state now is TTY_RQST
1271075108:239087 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075108:239166 tty: written 8 bytes
1271075108:239207 tty: request written (total 8 bytes)
1271075108:239247 tty: state now is TTY_RESP
1271075108:239290 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075108:293817 tty: response timeout
1271075108:293965 conn[192.168.8.204]: state now is CONN_RESP
1271075108:294007 tty: state now is TTY_PAUSE
1271075108:294050 conn_loop(): select(): max_sd = 6, t_out = 000000:100000
1271075108:294165 conn[192.168.8.204]: state now is CONN_HEADER
1271075108:294214 conn_loop(): select(): max_sd = 6, t_out = 000000:099950
1271075108:393815 conn_loop(): select(): max_sd = 6, t_out = 000000:000353
1271075108:394804 tty: state now is TTY_READY
1271075108:395525 conn_loop(): select(): max_sd = 6, t_out = 000009:000000
1271075117:294629 conn[192.168.8.204]: state now is CONN_RQST
1271075117:294796 conn[192.168.8.204]: state now is CONN_TTY
1271075117:294844 tty: state now is TTY_RQST
1271075117:295934 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075117:296014 tty: written 8 bytes
1271075117:296057 tty: request written (total 8 bytes)
1271075117:296099 tty: state now is TTY_RESP
1271075117:296142 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:350810 tty: response timeout
1271075117:350954 tty: attempt to retry request (1 of 10)
1271075117:350998 tty: state now is TTY_RQST
1271075117:352089 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:352168 tty: written 8 bytes
1271075117:352211 tty: request written (total 8 bytes)
1271075117:352252 tty: state now is TTY_RESP
1271075117:352297 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:406864 tty: response timeout
1271075117:407005 tty: attempt to retry request (2 of 10)
1271075117:407049 tty: state now is TTY_RQST
1271075117:408139 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:408218 tty: written 8 bytes
1271075117:408260 tty: request written (total 8 bytes)
1271075117:408301 tty: state now is TTY_RESP
1271075117:408346 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:462816 tty: response timeout
1271075117:462963 tty: attempt to retry request (3 of 10)
1271075117:463006 tty: state now is TTY_RQST
1271075117:464096 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:464176 tty: written 8 bytes
1271075117:464218 tty: request written (total 8 bytes)
1271075117:464259 tty: state now is TTY_RESP
1271075117:464304 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:518816 tty: response timeout
1271075117:518956 tty: attempt to retry request (4 of 10)
1271075117:519000 tty: state now is TTY_RQST
1271075117:520089 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:520169 tty: written 8 bytes
1271075117:520211 tty: request written (total 8 bytes)
1271075117:520252 tty: state now is TTY_RESP
1271075117:520297 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:574811 tty: response timeout
1271075117:574952 tty: attempt to retry request (5 of 10)
1271075117:575043 tty: state now is TTY_RQST
1271075117:576133 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:576213 tty: written 8 bytes
1271075117:576256 tty: request written (total 8 bytes)
1271075117:576296 tty: state now is TTY_RESP
1271075117:576341 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:630816 tty: response timeout
1271075117:630956 tty: attempt to retry request (6 of 10)
1271075117:630999 tty: state now is TTY_RQST
1271075117:632088 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:632166 tty: written 8 bytes
1271075117:632209 tty: request written (total 8 bytes)
1271075117:632250 tty: state now is TTY_RESP
1271075117:632294 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:686810 tty: response timeout
1271075117:686949 tty: attempt to retry request (7 of 10)
1271075117:686993 tty: state now is TTY_RQST
1271075117:688081 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:688160 tty: written 8 bytes
1271075117:688202 tty: request written (total 8 bytes)
1271075117:688243 tty: state now is TTY_RESP
1271075117:688287 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:742808 tty: response timeout
1271075117:742949 tty: attempt to retry request (8 of 10)
1271075117:742992 tty: state now is TTY_RQST
1271075117:744081 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:744160 tty: written 8 bytes
1271075117:744202 tty: request written (total 8 bytes)
1271075117:744244 tty: state now is TTY_RESP
1271075117:744288 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:798812 tty: response timeout
1271075117:798955 tty: attempt to retry request (9 of 10)
1271075117:798999 tty: state now is TTY_RQST
1271075117:800087 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:800166 tty: written 8 bytes
1271075117:800207 tty: request written (total 8 bytes)
1271075117:800250 tty: state now is TTY_RESP
1271075117:800294 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:854812 tty: response timeout
1271075117:854952 tty: attempt to retry request (10 of 10)
1271075117:854995 tty: state now is TTY_RQST
1271075117:856085 conn_loop(): select(): max_sd = 4, t_out = 000009:000000
1271075117:856163 tty: written 8 bytes
1271075117:856205 tty: request written (total 8 bytes)
1271075117:856248 tty: state now is TTY_RESP
1271075117:856292 conn_loop(): select(): max_sd = 4, t_out = 000000:054166
1271075117:910811 tty: response timeout
1271075117:910961 conn[192.168.8.204]: state now is CONN_RESP
1271075117:911004 tty: state now is TTY_PAUSE
1271075117:911048 conn_loop(): select(): max_sd = 6, t_out = 000000:100000
1271075117:911168 conn[192.168.8.204]: state now is CONN_HEADER
1271075117:911215 conn_loop(): select(): max_sd = 6, t_out = 000000:099949
1271075118:010812 conn_loop(): select(): max_sd = 6, t_out = 000000:000356
1271075118:011804 tty: state now is TTY_READY
1271075118:011862 conn_loop(): select(): max_sd = 6, t_out = 000010:000000
1271075123:723090 conn_close(): closing connection from 192.168.8.204
1271075123:723275 queue_delete_elem(): length now is 0
1271075123:723328 conn_loop(): select(): max_sd = 4, t_out = 000010:000000
1271075129:883963 Terminated by signal: SIGINT
(note that there is no problem with this Modbus client tcp because I checked it with other modbus gateways and I am sure that it is ok)

any body knows what is the problem ?


thanks for any help.
Best Regards for those who spend their time for helping the others that need it.

Last edited by golden_boy615; 04-11-2010 at 07:33 AM.
 
Old 04-13-2010, 05:06 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
For anything involving serial ports, first make sure you have a cable that works for the application. Also, make sure you are using the serial port that you think you are using, and that you have sufficient permissions to read/write to that port.

In your case, I would try connecting a known-working terminal/emulator (C-Kermit is my weapon of choice, but minicom is probably pre-installed on most linuxes, or use Windows Hyperterm), and connect the terminal as if it were the modbus server/PLC. Look for query data being sent from the modbus client (it won't be human-readable text, but you may be able to see patterns that make sense). Doing this serves to verify that your application is writing (or not) to the serial port in question. It does not verify the cabling, because the PLC may have a different pinout, which you should next verify.

--- rod.
 
Old 04-17-2010, 12:25 AM   #3
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Original Poster
Rep: Reputation: 18
I checked all of them (minicom) and I know that there is no problem with them .
 
Old 04-17-2010, 10:41 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, on closer scrutiny of your output, it appears that the connection between the PC and the modbus server/PLC is not behaving. Sometimes a connection is made, and at other times the PC times out waiting for a reply to a request. Is the modbus server concurrently connected to another client? I don't know modbus really well, but I know some PLCs are only capable of connecting to one client at a time. Can you verify that the problem still occurs when your PC client is the only client connected? It may be revealing to put a network snooper on the ethernet; wireshark or tcpdump (will require root privileges).
EDIT: One more thought; does your MODBUS/TCP application need to be compiled with special attention to network endian-ness? I think x86 and ARM use different native endian-ness, and there may be some build-time methods required to get that right.

--- rod.

Last edited by theNbomr; 04-17-2010 at 10:51 AM.
 
Old 04-30-2010, 11:55 AM   #5
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Original Poster
Rep: Reputation: 18
the cable and the connections are ok because I tested them with other operating system and other mbgateway.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing serial time out for modbus gateway golden_boy615 Linux - Software 0 04-11-2010 06:53 AM
LINUX modbus gateway golden_boy615 Linux - Software 8 03-28-2010 04:49 AM
Preempt RT and Modbus, can I?? webquinty Linux - Software 0 05-14-2009 01:46 PM
TCP IP Modbus boschow Programming 2 03-29-2008 04:43 AM
Tcp/ip Client Server Problem tushar123 Programming 2 03-31-2004 05:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration