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  2024  2025  <2026>  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  <2026> 
<== Date ==> <== Thread ==>

Subject: Re: Modbus Module issue
From: Luis Alberto De Sousa Moreira via Tech-talk <tech-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Sat, 25 Jul 2026 17:08:19 +0200
Hi Mark,

Bingo!
All is working now. I can connect and get the correct data.

Thank you all for the help.

Kind Regards
                   Luis

On 25/07/2026 16:35, Mark Rivers wrote:
You should just pull the master branch from GitHub.

Mark

Sent from my iPhone

On Jul 25, 2026, at 9:19 AM, Luis Alberto De Sousa Moreira <luis.moreira at epfl.ch> wrote:

 Hi Mark,
I'm using the latest version from I guess a week ago.
since you pushed the changes to the Master version, shall I just download that and build again or try to modify the version I have?
what is more useful for you?
Kind Regards
               Luis

On 25/07/2026 00:37, Mark Rivers wrote:
Luis,

The Github issue is this line in drvAsynIPPort.c:

which is this:
            if (connectResult < 0 && ((SOCKERRNO == EWOULDBLOCK) || (SOCKERRNO == EINPROGRESS))) {

This is incorrect, it should not be using EWOULDBLOCK and EINPROGRESS which are OS-dependent.  It should be using SOCK_EWOULDBLOCK and SOCK_EINPROGRESS which are defined in EPICS base and are OS-independent.  This bug was introduced in this commit on May 18, 2026.

What version of asyn are you using?  Is it a master branch more recent than May 18?

I don't understand why this code compiles at all on Windows.  EWOULDBLOCK and EINPROGRESS are used on Linux, MacOS, etc. but should not be defined at all on Windows.  Windows defines WSAEWOULDBLOCK and WSAEINPROGRESS which are functionally equivalent but have different numeric values.  SOCK_EWOULDBLOCK and SOCK_EINPROGRESS are defined as EWOULDBLOCK and EINPROGRESS or WSAEWOULDBLOCK and WSAEINPROGRESS depending on the OS.

I just reproduced the issue on my system with base 7.0.10 and the master branch of asyn.  I am using Visual Studio 2022.   I see this when I try to connect to a known working terminal server:

# This is for Digi SP One
drvAsynIPPortConfigure("serial1", "gsets13:2101", 0, 0, 0)
2026/07/24 17:24:46.862 serial1 -1 autoConnect could not connect: Can't connect to gsets13:2101: Unknown error

I then changed drvAsynIPPort.c to replace EWOULDBLOCK and EINPROGRESS with SOCK_EWOULDBLOCK and SOCK_EINPROGRESS on line 530.  That fixed the problem.

I have pushed the fix to the asyn master branch on Github.

Mark


From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: Friday, July 24, 2026 9:43 AM
To: Luis Alberto De Sousa Moreira <luis.moreira at epfl.ch>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Modbus Module issue

Hi Luis,

Can you try making the change around line 531 in drvAsynIPPort.c that is described in the Github issue, replacing  EWOULDBLOCK and EINPROGRESS with SOCK_EWOULDBLOCK and SOCK_EINPROGRESS?


Mark



From: Luis Alberto De Sousa Moreira <luis.moreira at epfl.ch>
Sent: Friday, July 24, 2026 9:36 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Mark Rivers <rivers at cars.uchicago.edu>
Subject: Re: Modbus Module issue
 
Hi Mark,
Just tried everything on your list and the error is the same in all instances.

Kind Regards 
                   Luis

On 24/07/2026 16:24, Luis Alberto De Sousa Moreira via Tech-talk wrote:
Hi Mark,
Will try your suggestions and will let you know the result. The Github issue does seem suspiciously similar.

Thank you.
Kind Regards
              Luis


On 24/07/2026 15:03, Mark Rivers wrote:
Hi Luis,

This does look like there is an issue with drvAsynIPPortConfigure on your machine.  The "Unknown error" message seems strange.  You could try the following:

  • Change the IP address from 10.136.0.30 to a non-existent IP address on your subnet.  Does the error message change?
  • Change port 502 to a port that won't be supported, like 501.  Does the error message change?
  • Switch to an IP address and port of another server that should connect, for example port 80 on a Web server.  Does that connect?  I want to see if drvAsynIPPort is working at all.

Just a few minutes ago someone opened this Github issue

It reports a problem with drvAsynIPPortConfigure() on Windows failing with "Unknown error".  This seems suspiciously similar.

Mark



From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Luis Alberto De Sousa Moreira via Tech-talk <tech-talk at aps.anl.gov>
Sent: Friday, July 24, 2026 7:12 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Modbus Module issue
 
Hi Guys,
I think I tried everything I can think off. Still no connection.
May AI assistant thinks that the issue is that the module was built using MinGW instead of the MSVC tool chain, it is talking about the fact that MinGW uses a "Translation Layer" (POSIX vs. Winsock). I never had any issues before so can't see that being the issue, but wondering what you thoughts are on this.

Kind Regards
                 Luis

On 24/07/2026 10:46, Luis Alberto De Sousa Moreira via Tech-talk wrote:
Hi  Jörn,
I think we getting the wires crossed here... the OPCUA port is 4840 but the 502 port is the normal Modbus port. 
I managed to connect fine to it with other applications in the same machine.

<guqfI6cC6AdYLRNq.png>



Kind Regards
                  Luis


On 24/07/2026 10:38, Jörn Dreyer wrote:
Hi Luis, are you sure you are using the correct port? The Beckhoff documentation tells that the OPCUA server is listening on port 4840.  Did you cahnge that when installing the OPCUA Sever on the PLC? The Ports 500 + x are normally used for the various NC applications in your PLC program. Regards Jörn Am Freitag, 24. Juli 2026, 09:57:38 Mitteleuropäische Sommerzeit schrieb Luis Alberto De Sousa Moreira via Tech-talk:
Just found another application I used before as a Modbus client, called EasyModbusClient. It connects fine and gets data. This is getting more intriguing... Best Regards                   Luis On 24/07/2026 09:40, Luis Alberto De Sousa Moreira via Tech-talk wrote:
Hi Gabriel, The firewall seems to be the culprit, but I added rules for the application. I also just done a test where I disabled the firewall and I get the same result. D:\FalconDev\EPICS\modbus\iocBoot\iocTest>..\..\bin\windows-x64-mingw\modbusApp.exe BPS_Beck.cmd # BPS_Beck.cmd # Just testing the modbus module with my BPS Beckhoff PLC. # 1. Cleanly lock network routing automatically at boot epicsEnvSet("EPICS_CA_ADDR_LIST", "10.136.0.255") epicsEnvSet("EPICS_CA_AUTO_ADDR_LIST", "NO") epicsEnvSet("EPICS_CAS_INTF_ADDR_LIST", "10.136.0.34") # gvl.mb_Input_Registers[10] := GVL.d_setpoint_T1;              // T1                   mS # gvl.mb_Input_Registers[11] := GVL.d_setpoint_TRamp1;  // Ramp1              uS # gvl.mb_Input_Registers[12] := GVL.d_setpoint_v1;              // V1                   10V # gvl.mb_Input_Registers[13] := GVL.d_setpoint_T2;              // T2                   mS # gvl.mb_Input_Registers[14] := GVL.d_setpoint_TRamp2;  // Ramp2              uS # gvl.mb_Input_Registers[15] := GVL.d_setpoint_V2;              // V2                   10V # gvl.mb_Input_Registers[16] := GVL.d_setpoint_T3;              // T3                   mS # gvl.mb_Input_Registers[17] := GVL.d_setpoint_TRamp3;  // Ramp3              uS # gvl.mb_Input_Registers[18] := GVL.d_setpoint_V3;              // V3                   10V # gvl.mb_Input_Registers[19] := GVL.d_setpoint_pulseLength;     // PulseLength  S /mS # gvl.mb_Input_Registers[20] := GVL.d_setpoint_TRampDown;       // RampDown             uS dbLoadDatabase("../../dbd/modbusApp.dbd") modbusApp_registerRecordDeviceDriver(pdbbase) # Get the connection going drvAsynIPPortConfigure("BPS_Beck", "10.136.0.30:502", 0, 0, 0) 2026/07/24 09:32:59.953 BPS_Beck -1 autoConnect could not connect: Can't connect to 10.136.0.30:502: Unknown error # drvAsynIPPortConfigure("BPS_Beck", "8.8.8.8:8080", 0, 0, 0) modbusInterposeConfig("BPS_Beck", 0, 5000, 0) asynSetOption("BPS_Beck",0, "disconnectOnReadTimeout", "Y") # ========================================================================= # Configure Modbus Drivers Memory Blocks # ========================================================================= # Syntax: # drvModbusAsynConfigure("portName", "tcpPortName", slaveAddress, modbusFunction, modbusStartAddress, modbusLength, dataType, pollMsec, "plcType") # drvModbusAsynConfigure("modbusPortName", "asynPortName", slaveAddress, modbusFunction, startAddress, length, dataType, pollMsec, "plcType") # Read Coils (Function Code 1) # Reads 16 binary bits starting at offset 0, polling every 200 milliseconds. # drvModbusAsynConfigure("READ_COILS", "PLC_NET", 0, 1, 0, 1, 0, 200, "OldPLC") # Write Coils (Function Code 5) # Configures a write-only path for coils. pollMsec is 0 because writes are instantaneous. # drvModbusAsynConfigure("WRITE_COILS", "PLC_NET", 0, 5, 0, 1, 0, 0, "OldPLC") # Reads 11 read-only 16-bit registers starting at offset 10, polling every 500 milliseconds. # dataType=0 specifies standard 16-bit unsigned integers (UINT_16). drvModbusAsynConfigure("READ_INPUTS", "BPS_Beck", 1, 4, 10, 11, 0, 500, "Beckhoff") # Read Holding Registers (Function Code 3) # Reads 1 read/write 16-bit register starting at offset 0, polling every 500 milliseconds. # dataType=0 specifies standard 16-bit unsigned integers (UINT_16). # drvModbusAsynConfigure("READ_HOLDING", "PLC_NET", 0, 3, 0, 1, 0, 500, "OldPLC") # Block E: Write Holding Registers (Function Code 6) # Configures a write-only path for single registers. pollMsec is 0 for on-demand writing. # drvModbusAsynConfigure("WRITE_HOLDING", "PLC_NET", 0, 6, 0, 1, 0, 0, "OldPLC") # Enable ASYN_TRACEIO_HEX on octet server # asynSetTraceIOMask("BPS_Beck",0,4) # Enable ASYN_TRACE_ERROR and ASYN_TRACEIO_DRIVER on octet server # asynSetTraceMask("BPS_Beck",0,9) dbLoadRecords("../../db/BPS_Beck.db") iocInit Starting iocInit ############################################################################ ## EPICS R7.0.10 ## Rev. 2026-07-01T08:47+0200 ## Rev. Date build date/time: ############################################################################ 2026/07/24 09:33:00.992 drvModbusAsyn::doModbusIO port READ_INPUTS error calling writeRead, error=asynManager::queueLockPort queueRequest failed: port BPS_Beck not connected, nwrite=0/6, nread=0 iocRun: All initialization complete epics> Kind Regards                 Luis On 23/07/2026 16:24, Gabriel Fedel wrote:
Hi Luis, Couldn't the firewall be blocking  the EPICS application ? Best Regards Gabriel ------------------------------------------------------------------------ *From:* Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Luis Alberto De Sousa Moreira via Tech-talk <tech-talk at aps.anl.gov> *Sent:* Thursday, July 23, 2026 3:59 PM *To:* Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov> *Subject:* Re: Modbus Module issue Hi Mark, My other application is using the Modbus protocol, I used it to do the initial testing on my system. I tried the telnet command from my MSYS2 environment and it can connect... telnet 10.136.0.30 502 Trying 10.136.0.30... Connected to 10.136.0.30. Escape character is '^]'. Kind Regards                   Luis On 23/07/2026 15:31, Mark Rivers wrote:
telnet 10.136.0.30 502

-- Luis Moreira EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13 CH-1015 Lausanne, Switzerland Tel.    (+41) 21 693 58 37 E-Mail  luis.moreira at epfl.ch


-- Luis Moreira EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13 CH-1015 Lausanne, Switzerland Tel.    (+41) 21 693 58 37 E-Mail  luis.moreira at epfl.ch


-- Luis Moreira EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13 CH-1015 Lausanne, Switzerland Tel.    (+41) 21 693 58 37 E-Mail  luis.moreira at epfl.ch


-- Luis Moreira EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13 CH-1015 Lausanne, Switzerland Tel.    (+41) 21 693 58 37 E-Mail  luis.moreira at epfl.ch


-- 
Luis Moreira
EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13
CH-1015 Lausanne, Switzerland
Tel.    (+41) 21 693 58 37
E-Mail  luis.moreira at epfl.ch


-- 
Luis Moreira
EPFL SB SPC-II, PPH241 (Batiment PPH) Station 13
CH-1015 Lausanne, Switzerland
Tel.    (+41) 21 693 58 37
E-Mail  luis.moreira at epfl.ch


References:
Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Jörn Dreyer via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Mark Rivers via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Mark Rivers via Tech-talk
Re: Modbus Module issue Mark Rivers via Tech-talk
Re: Modbus Module issue Luis Alberto De Sousa Moreira via Tech-talk
Re: Modbus Module issue Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Modbus Module issue Mark Rivers via Tech-talk
Next: Window build error - can find script. [SEC=OFFICIAL] STARRITT, Andrew 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  2024  2025  <2026> 
Navigate by Thread:
Prev: Re: Modbus Module issue Mark Rivers via Tech-talk
Next: Create record name manifest during build David Bracey 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  2024  2025  <2026> 
ANJ, 27 Jul 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·