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 <2024> 2025 | 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 <2024> 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: An error occurred while using aSub to process Modbus data |
From: | Mark Rivers via Tech-talk <tech-talk at aps.anl.gov> |
To: | LONG FENG <feng98716 at gmail.com>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Tue, 5 Nov 2024 23:08:37 +0000 |
Hi Feng, As several of us said in response to your original post, the best way to do this is with the EPICS Modbus driver. You have been trying for over a week to do it, first with streamDevice
and now with asub. Here is all you need to do it with the Modbus driver drvAsynSerialPortConfigure("SI", "/dev/ttyS3") #modbusInterposeConfig(const char *portName, # modbusLinkType linkType, # 0=TCP, 1=RTU, 2=ASCII # int timeoutMsec, # int writeDelayMsec) modbusInterposeConfig("SI", 1, 1000, 50) # drvModbusAsynConfigure( # char *portName, # char *octetPortName, # int modbusSlave, # int modbusFunction, # int modbusStartAddress, # int modbusLength, # modbusDataType dataType, # int pollMsec, # char *plcType) # Read 6 registers. Function code=4. Poll every 1000 ms drvModbusAsynConfigure("SI_REG_IN", "SI", 1, 4, 0, 6, 0, 1000, "Pressure") ## Load record instances dbLoadRecords("../../db/RS485Test.db") Change RS485Test.db to the following. This should put the first 4 bytes (2 registers) into the Dose longin record as a 32-bit integer, and then put the next 2 bytes (1 register) into the
Units mbbi record. record(ai, "Sensor:Dose") { field(DTYP, "asynInt32") field(INP,"@asyn(SI_REG_IN 0)INT32_LE") field(SCAN, "I/O Intr") } record(mbbi, "Sensor:Units") { field(DTYP, "asynInt32") field(INP, "@asyn(SI_REG_IN 2)INT16") field(ZRVL, "1" field(ZRST, "CPS" field(ONVL, "2" field(ONST, "CPM" field(TWVL, "3" field(TWST, "
uSv/h" field(SCAN, "I/O Intr") } I can’t test this, so there could be some minor errors. But it should work once those are fixed. You can change the longin record to an ai record if you need to apply scaling, etc. Mark From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of LONG FENG via Tech-talk Hi all, I want to process Modbus format data, but it's not going very smoothly. My record file content is as follows: record(waveform, "Sensor:waveform") dose.c: #include <epicsExport.h> I used caget to observe Sensor:ai, and the result is always: Sensor:ai 2.20405e-38 I think I made a mistake in my processing function, so I wrote a simple test program as follows: #include <epicsExport.h> #include <aSubRecord.h> However, the result is always: Sensor:ai 0 What should I modify? Please help me. Feng |