EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Question about the connection refused
From: Mark Rivers <[email protected]>
To: lzfneu <[email protected]>, Mark Engbretson <[email protected]>, "[email protected]" <[email protected]>
Date: Mon, 28 Mar 2016 13:07:19 +0000
Hi Zhefu,

I just realized the likely source of your problem.  It is this command:

modbusInterposeConfig("UCOS123",2,0,2000)

You have specified link type 2, which is Modbus ASCII.  Are you sure that your device uses Modbus ASCII, and not Modbus TCP or Modbus RTU?  You need to read the manual to figure out what Modbus protocol the device actually uses.

You have also specified a write delay of 2000 ms.  This seems wrong.  That delay is normally only needed for Modbus RTU devices, and it is typically only 3 or 4 ms, not 2000 ms.

Mark

________________________________
From: Mark Rivers
Sent: Monday, March 28, 2016 5:45 AM
To: lzfneu; Mark Engbretson; [email protected]
Subject: RE: Question about the connection refused

Hi Zhefu,

There could be a problem with this command:

> drvModbusAsynConfigure("read123", "UCOS123", 0, 3, 0, 95, 0, 1140,"M22A")

You have set a poll time of 1140 ms, or 1.140 seconds.  That may be too long, and the device is timing out because of too long a period of inactivity.  I suggest you change 1140 to 100.

For this command the timeout value is set to 10000 ms.  That is not "wrong" because any non-zero value means it should do one initial write.  However, to make it clear that it is simply a flag, and not a time, I suggest changing 10000 to 1.

> drvModbusAsynConfigure("write123", "UCOS123", 0, 16, 48, 8, 0, 10000, "M22A")

To debug your problem you need to look at the communication between the IOC and the device.  You can do that with asynTrace.  Right after this command

drvAsynIPPortConfigure("UCOS123","192.168.1.125:502",0,0,1)

add these 2 commands:

asynSetTraceIOMask("UCOS123", 0, 4)
asynSetTraceMask("UCOS123", 0, 9)

4 means ASYN_TRACEIO_HEX and 9 means ASYN_TRACE_ERROR and ASYN_TRACEIO_DRIVER.

You will now see all of the communication between the IOC and the device.

Please send the complete IOC output again after you make these changes.

Mark


________________________________
From: lzfneu [[email protected]]
Sent: Sunday, March 27, 2016 11:02 PM
To: Mark Rivers; Mark Engbretson; [email protected]
Subject: RE: Question about the connection refused

Hi Mark,

Thanks for your respond.

I have tested the IP address and port 502 using ping 192.168.1.125 and telnet 192.168.1.125 502 and the radiation monitor and computer commuicate well.
If I understand right, a write command should be added in .cmd file.

So, I write a simple test.cmd file containing four commands just for test:

#!../../bin/linux-x86/modbusApp
< envPaths

dbLoadDatabase("../../dbd/modbus.dbd")
modbus_registerRecordDeviceDriver(pdbbase)

# Use the following commands for TCP/IP
drvAsynIPPortConfigure("UCOS123","192.168.1.125:502",0,0,1)

modbusInterposeConfig("UCOS123",2,0,2000)

# Read 100 words (1600 bits).  Function code=3.
drvModbusAsynConfigure("read123", "UCOS123", 0, 3, 0, 95, 0, 1140,"M22A")

# Write 8 words (128 bits).  Function code=16
drvModbusAsynConfigure("write123", "UCOS123", 0, 16, 48, 8, 0, 10000, "M22A")

iocInit


After start running, the error messages shown in the following terminal window:

[cid:inlineImage0]

Could you plesase help me and thanks in advance.

Best regards,

Zhefu


> From: [email protected]
> To: [email protected]; [email protected]
> Subject: RE: Question about the connection refused
> Date: Fri, 25 Mar 2016 13:01:51 +0000
>
> Hi Zhefu,
>
> Please send the complete output when you start the IOC and get the errors.
>
> One possibility is that is does initially connect OK, but then it is timing out. Are you only creating drvAsymModbus ports for output bits, or do you also create some for inputs? If you only create outputs then that can be a problem. The reason is that many PLCs will close the socket connection after a few seconds of inactivity. If you only have output ports connected to the PLC that can happen, because the outputs are not processed very frequently. If you create an input port that will normally be rapidly pollled, and will prevent the socket from timing out. This is discussed in my EPICS Modbus documentation here:
>
> http://cars.uchicago.edu/software/epics/modbusDoc.html
>
> It says:
>
> ***********
>
> It is important to note, however, that many PLCs will time out sockets after a few seconds of inactivity. This is not a problem with modbus drivers that use read function codes, because they are polling frequently. But modbus drivers that use write function codes may only do occasional I/O, and hence may time out if they are the only ones communicating through a drvAsynIPPort driver. Thus, it is usually necessary for modbus drivers with write function codes to use the same drvAsynIPPort driver (socket) as at least one modbus driver with a read function code to avoid timeouts.
>
> ***********
>
> Mark
>
> ________________________________
> From: Mark Rivers
> Sent: Friday, March 25, 2016 7:07 AM
> To: lzfneu; [email protected]
> Subject: RE: Question about the connection refused
>
> Hi Zhefu,
>
> You said:
> > I performed the ping 192.168.1.125:502 command and found that the computer and radiation monitor counter connected well.
>
> That does not make sense to me. Are you sure you had the :502 at the end? That should not work. It should work if you omit the :502.
>
> This works for me:
> ping 164.54.160.158
> PING 164.54.160.158 (164.54.160.158) 56(84) bytes of data.
> 64 bytes from 164.54.160.158: icmp_req=1 ttl=64 time=1.46 ms
> 64 bytes from 164.54.160.158: icmp_req=2 ttl=64 time=0.891 ms
>
> This does not work:
> corvette:CARS/iocBoot/ioc13GasLoading>ping 164.54.160.158:502
> ping: unknown host 164.54.160.158:502
>
> Here is a way to see if your device is responding on the Modbus port 502
>
> telnet 192.168.1.125 502
>
> This is what I get when I try to telnet into a Modbus PLC
>
> >telnet 164.54.160.158 502
> Trying 164.54.160.158...
> Connected to 164.54.160.158.
> Escape character is '^]'.
>
> This is what I get when I try to telnet into a Linux computer that does not support Modbus
>
> >telnet 164.54.160.82 502
> Trying 164.54.160.82...
> telnet: connect to address 164.54.160.82: Connection refused
>
> Does your radiation monitor actually support Modbus? If so, how many simultaneous socket connections does it allow? Perhaps you already have some other software connected to it on port 502?
>
> Mark
>
>
>
>
> ________________________________
> From: lzfneu [[email protected]]
> Sent: Thursday, March 24, 2016 11:22 PM
> To: Mark Rivers; [email protected]
> Subject: RE: Question about the connection refused
>
> Hi Mark,
>
> Actually, I need to read the dose rate from a radiation monitor counter by using epics.
>
> I installed the asyn4-29 and modbusR2-8 packages.
>
> As a new user in epics, I edited the modbus ioc example in iocTest folder and the file named Koyo1.cmd:
> I changed the IPaddress to the actual IPaddress of radiation monitor counter.
>
> drvAsynIPPortConfigure ("Koyo1","192.168.1.125:502",0,0,1)
>
> after starting the ioc:
> > $ modbusApp Koyo1.cmd
>
> the first error occurs in command:
> # write 32 bits (Y0-Y37). Function code = 5
> drvModbusAsynConfigure("K1_Yn_Out_Bit", "Koyo1", 0, 5, 04000, 040, 0, 1, "Koyo")
>
> 2016/03/25 11:33:29.067 drvModbusAsyn::doModbusIO port K1_Yn_Out_Bit error calling writeRead, error =192.168.1.235:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
>
> and the sequenct errors were:
> # Write 8 words (128 bits). Function code=6.
> drvModbusAsynConfigure("K1_Yn_Out_Word", "Koyo1", 0, 6, 040500, 010, 0, 100, "koyo")
> drvModbusAsyn
>
> 2016/03/25 11:33:34.073 drvModbusAsyn::doModbusIO port K1_Xn_Bit error calling writeRead, error=192.168.1.125:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
> 2016/03/25 11:33:39.078 drvModbusAsyn::doModbusIO port K1_Xn_Word error calling writeRead, error=192.168.1.125:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
> 2016/03/25 11:33:44.084 drvModbusAsyn::doModbusIO port K1_Yn_In_Bit error calling writeRead, error=192.168.1.125:502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0
>
> I have to stop the output in the terminal window.
>
> I performed the ping 192.168.1.125:502 command and found that the computer and radiation monitor counter connected well.
>
> It seems the read and write error occurs when they communicate with each other.
>
> I am confused and really don't know how to do next. Could you plesase help me and thanks in advance.
>
> Best regards,
>
> Zhefu
>
>
> > From: [email protected]
> > To: [email protected]; [email protected]
> > Subject: RE: Question about the softioc connection refused ?
> > Date: Sat, 19 Mar 2016 12:55:02 +0000
> >
> > Hi Zhefu
> >
> > > I edited the Koyo1.cmd file to change the ip address in function with two conditions:
> > > 1) drvAsynIPPortConfigure("Koyo1","127.0.0.1:5065",0,0,1)
> > > where 127.0.0.1:5065 is my localhost ip address.
> >
> > This is not correct. You have specified port 5065 for the drvAsynIPPort driver that is supposed to connect to a Modbus server. Port 5065 is not used for Modbus, it is used for EPICS channel access.
> >
> > You cannot run the test application in the Modbus directory unless you actually have a Modbus server that you can connect to. Do you actually have a Modbus server? If so, then you specify its IP address and port 502 in the drvAsynIPPortConfigure command.
> >
> > Mark
> >
> >
> > ________________________________
> > From: [email protected] [[email protected]] on behalf of lzfneu [[email protected]]
> > Sent: Saturday, March 19, 2016 7:26 AM
> > To: [email protected]
> > Subject: Question about the softioc connection refused ?
> >
> > hi,
> >
> > I have encountered another softioc connection problem:
> >
> > I have insatlled modbus-R2-8, and want to run test example (file named Koyo1.cmd) in the iocTest folder.
> >
> > I edited the Koyo1.cmd file to change the ip address in function with two conditions:
> >
> > 1) drvAsynIPPortConfigure("Koyo1","127.0.0.1:5065",0,0,1)
> > where 127.0.0.1:5065 is my localhost ip address.
> >
> > 2) drvAsynIPPortConfigure("Koyo1","192.168.1.255:5065",0,0,1)
> > where 192.168.1.255:5065 is my broadcast ip address that obtained by command ifconfig.
> >
> > after starting the ioc:
> > $ modbusApp Koyo1.cmd
> >
> > the results are both two ip address cannot connect the Koyo1, the error messages are shown below:
> >
> > 1) drvAsynIPPortConfigure("Koyo1","127.0.0.1:5065",0,0,1)
> > 2016/03/19 19:40:19.158 Can't connect to 127.0.0.1:5065: Connection refused Koyo1 -1 autoConnect could not connect
> >
> > 2) drvAsynIPPortConfigure("Koyo1","192.168.1.255:5065",0,0,1)
> > 2016/03/19 20:19:49.083 Can't connect to 192.168.1.255:5065: Network is unreachable Koyo1 -1 autoConnect could not connect
> >
> > I am new in epics, could you plesase help me and thanks in advance.
> >
> > Best regards
> >
> > Zhefu
> >

PNG image


Replies:
RE: Question about the connection refused lzfneu
References:
Question about the softioc connection refused ? lzfneu
RE: Question about the softioc connection refused ? Mark Rivers
RE: Question about the connection refused lzfneu
RE: Question about the connection refused Mark Rivers
RE: Question about the connection refused Mark Rivers
RE: Question about the connection refused lzfneu
RE: Question about the connection refused Mark Rivers

Navigate by Date:
Prev: RE: Question about the connection refused Mark Rivers
Next: RE: FFT and waveform Gofron, Kazimierz
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Question about the connection refused Mark Rivers
Next: RE: Question about the connection refused lzfneu
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·