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  2016  2017  2018  2019  2020  2021  2022  2023  <20242025  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
<== Date ==> <== Thread ==>

Subject: Re: streamDevice configuration issues with serial ports
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: Michael Davidsaver <mdavidsaver at gmail.com>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 29 Oct 2024 04:24:16 +0000
I agree with Michael, the Modbus driver may be better, especially if there are multiple registers to read.

If you want to use streamDevice instead then here are some of the things you are doing wrong.

- Modbus RTU does not use terminators, so you need to remove those from you protocol file.

- Your command needs to end with the correct CRC. streamDevice can compute that, or you can hardcode it if your command is always the same.

- You cannot read the response with a simple %r because the first few bytes of the response contain the device address, the function code, and the response length. The actual data comes after those. 

Mark

Sent from my iPhone

> On Oct 28, 2024, at 11:04 PM, Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov> wrote:
> 
> On 10/28/24 18:26, LONG FENG via Tech-talk wrote:
>> Hi all,
>> I have a sensor that communicates via RS485 with the Modbus RTU protocol. I want to use streamDevice
> 
> I would recommend investigating the dedicated modbus driver.
> 
> https://urldefense.us/v3/__https://github.com/epics-modules/modbus__;!!G_uCfscf7eWS!c4aIWok1tNUpdvoK687_GbGUCAbx6C1QeCs-S8lpaB_ezoWQZwEjMofav56BrZ-IOIyZ5jrM53AfDHb1aGIp4Bo3OQ$
> 
>> to read the sensor values, but I've found that there is no data transmission between the system and the sensor, and the following issues have occurred:
>> /epics> 2024/10/28 21:00:05.370941 SI Sensor:Data: No reply within 10000 ms to "<01><04><00><00><00><06>p<08><0d><0a>"
>> 2024/10/28 21:00:20.484243 SI Sensor:Data: No reply within 10000 ms to "<01><04><00><00><00><06>p<08><0d><0a>"
>> 2024/10/28 21:00:35.322913 SI Sensor:Data: No reply within 10000 ms to "<01><04><00><00><00><06>p<08><0d><0a>"
>> 2024/10/28 21:00:50.427348 SI Sensor:Data: No reply within 10000 ms to "<01><04><00><00><00><06>p<08><0d><0a>"
>> /
>>     My protocol(RS485Test.proto) file is written like this:
>> /
>> /
>> /Terminator = CR LF;
>> InTerminator = CR LF;
>> ReplyTimeout = 10000;
>> ReadTimeout = 10000;
>> getData
>> {
>>   out "\x01\x04\x00\x00\x00\x06\x70\x08";
>>   in "%r";
>> }
>> /
>>     Record(RS485Test.db):
>> /record(ai, "Sensor:Data")
>> {
>>     field(DTYP, "stream")
>>     field(INP, "@RS485Test.proto getData SI")
>>     field(SCAN, "5 second")
>> }
>> /
>> /
>> /
>>     IOC st.cmd:
>> /
>> /
>> /#!../../bin/linux-x86_64/dataProcessing
>> < envPaths/
>> /
>> dbLoadDatabase("../../dbd/dataProcessing.dbd",0,0)
>> dataProcessing_registerRecordDeviceDriver pdbbase
>> epicsEnvSet ("STREAM_PROTOCOL_PATH", "/home/training/examples/dataProcessingApp/Db")
>> drvAsynSerialPortConfigure("SI", "/dev/ttyS3")
>> asynSetOption("SI", 0, "baud", "9600")
>> asynSetOption("SI", 0, "bits", "8")
>> asynSetOption("SI", 0, "parity", "none")
>> asynSetOption("SI", 0, "stop", "1")
>> asynSetOption("SI", 0, "clocal", "Y")
>> asynSetOption("SI", 0, "crtscts", "N")
>> ## Load record instances
>> dbLoadRecords("../../db/RS485Test.db")
>> iocInit()/
>>     Is there anything wrong with these?
> 

References:
streamDevice configuration issues with serial ports LONG FENG via Tech-talk
Re: streamDevice configuration issues with serial ports Michael Davidsaver via Tech-talk

Navigate by Date:
Prev: Re: streamDevice configuration issues with serial ports Michael Davidsaver via Tech-talk
Next: AW: asyn port locking while motorIMS controller limit-switch configuration is read Eckert, Sebastian via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
Navigate by Thread:
Prev: Re: streamDevice configuration issues with serial ports Michael Davidsaver via Tech-talk
Next: RE: streamDevice configuration issues with serial ports Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
ANJ, 29 Oct 2024 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·