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  <20232024  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  <20232024 
<== Date ==> <== Thread ==>

Subject: Re: Help: Asyn record getting incomplete input
From: "Marco A. Barra Montevechi Filho via Tech-talk" <tech-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Date: Mon, 9 Jan 2023 16:36:54 +0000
Ok, so i think verything is clear now. Thanks!

Best regards,

Marco

From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 09 January 2023 12:59
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: Re: Help: Asyn record getting incomplete input
 
I believe some data might be mixing up in the way but it is probably not related to the asyn record itself. Capturing some packets might get me the answers i need now.

Before capturing packets I would suggest simply enabling asynTrace to see the communication from the device.  Each block of data received will have a timestamp and number of characters, so you can understand that.

Im still not familiar with what is queueLockPortTimeout. I assume it is a request by the asynRecord to use the port and it can wait a given amount of time until it raises an exception and gives up processing the I/O operation, is that right? 

That is basically correct.  All requests for I/O to asyn devices is done with a call to pasynManager->queueRequest.  There is a timeout associated with that request, so that if the request does not make it to the top of queue and get executed within that timeout period then the request is cancelled and an error message is printed.

Mark



From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Sent: Monday, January 9, 2023 9:41 AM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: Re: Help: Asyn record getting incomplete input
 
Worked! Thanks!

So, caget seems to get me the complete value of table or at least some of it. I believe some data might be mixing up in the way but it is probably not related to the asyn record itself. Capturing some packets might get me the answers i need now.

I don't understand what you are saying.  265337 is much more than 860.  Why do you say 860 when dbgf says it is 800?

Im not sure if i understood your question also, but i copied the the table values shown by dbgf to a file and used wc --chars to count how many chars are written: 863. I guessed 265337 is much more than whats in 863 chars since 863*8=6904. But with your last answer everything makes sense anyway.

You need to think about how your read command should terminate

Thanks for the tip. Unfortunately the table is badly formatted and has no terminator and no fixed number of bytes, so currently my only option is timeout.
By the way: the table takes a LOT of time to arrive. Does that mean that the queueLockPortTimeout was because i was still receiving the table and the poller could not ask for position? Is there any way to be sure of this? I ask because i can lose some position data with no problem, but i can not lose any table data.

Im still not familiar with what is queueLockPortTimeout. I assume it is a request by the asynRecord to use the port and it can wait a given amount of time until it raises an exception and gives up processing the I/O operation, is that right? 

Thanks for your patience,

Marco

From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 09 January 2023 12:21
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: Re: Help: Asyn record getting incomplete input
 
Hi Marco,

Also, NORD field is now with value 265337, which kinda makes sense but isnt this much more bytes than the 860 characters that i got in the table shown?

I don't understand what you are saying.  265337 is much more than 860.  Why do you say 860 when dbgf says it is 800?

I think I understand the problem.  This is the source code for dbgf in the current master of EPICS base.


Note that it simply uses 

    long buffer[100];

On 64-bit Linux long is 8 bytes, so the buffer is 800 bytes.  I believe this is why dbgf is reporting that the size is 800.  So I think the asyn record is work, the problem is just that dbgf truncates the output.

Please use caget (with a large EPICS_CA_MAX_ARRAY_BYTES) to see the entire contents of the .BINP field.

Please send the output of this command after you successfully get NORD=265337

 dbpr $(DEV)asynEth 2

You need to think about how your read command should terminate when you ask it to read the table.  With the asyn driver a read will terminate when any of the following occurs:

  • The terminator is received.  In your case you have disabled terminators by setting IEOS="".
  • The requested number of characters are received.  In your case IMAX=520000 which is more characters than the device will send, so this will not cause the read to terminate.
  • An "End of Message" is received.  I think this really only applies to GPIB.
  • The read request times out.
So in your case the read will only terminate when it times out.

Mark


From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Sent: Monday, January 9, 2023 8:50 AM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: Re: Help: Asyn record getting incomplete input
 
Hi Mark, thanks for the quick answer!

I did comment out the 
PI_GCS2_CreateController("E873", "E873_ETH", 1, 0, 0, 50, 1000)
Line and the error itself stopped showing but the table keeps comming incomplete, chopped off exactly in the same place.
I tried messing with asynSetQueueLockPortTimeout but the IOC sigfaulted (i suppose i have to update asyn version).

With the motorcontroller line commented out, i can see:

epics> dbpf $(DEV)asynEth.AOUT "DRR?"
DBR_STRING:          "DRR?"  
epics> 2023/01/09 11:43:56.764 MGN:A:E873:DIAG:A:asynEth: nwrite=4, status=0, nawt=4
DRR?

epics> dbgf $(DEV)asynEth.BINP #(Nothing came yet)
epics> dbgf $(DEV)asynEth.BINP #(Nothing came yet)
epics> 2023/01/09 11:44:10.270 MGN:A:E873:DIAG:A:asynEth: inlen=265337, nbytesTransfered=265337, ntranslate=272968
epics>epics> dbgf $(DEV)asynEth.BINP #(Now i have info)
DBR_CHAR[800]:      
 "# REM E-873
#
# VERSION = 1
# TYPE = 1
# SEPARATOR = 32
(Etc.)

Also, NORD field is now with value 265337, which kinda makes sense but isnt this much more bytes than the 860 characters that i got in the table shown? The fact that the table always comes with the values truncated in the exact same number of chars leads me to believe that im naively forgetting some parameter that tells the BINP field how much it should store or show to the user...



From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 09 January 2023 10:56
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Cc: SWC <swc at lnls.br>
Subject: Re: Help: Asyn record getting incomplete input
 
Hi Marco,

> But i just get a small part of the table, which start right but just cuts out after some chars. It seems to always cut at 860 chars. I tried messing with IMAX but this doesnt seem to be the problem. 

This is the error you get:

epics> 2023/01/09 09:40:39.129 PIInterface::sendAndReceive error calling writeRead, output=4 status=3, error=asynManager::queueLockPort queueRequest timed out

Note that the error is that queueLockPort timed out.  That means that someone else has the port locked for longer than the timeout, probably the motor driver.

You said:

> Since im not trying to actually control the motor for now but just get some information from it, i didnt even load the motor records.

But you did load the motor driver itself, so it is polling the controller:

PI_GCS2_CreateController("E873", "E873_ETH", 1, 0, 0, 50, 1000)

In order to understand what is going on you should uncomment these lines:

#asynSetTraceMask("E873_ETH",0,3)
#asynSetTraceIOMask("E873_ETH",0,1)


and change them to this:

asynSetTraceMask("E873_ETH",0,ERROR|DRIVER)
asynSetTraceIOMask("E873_ETH",0,ESCAPE)

You might want to comment out the line that starts the controller to see if you still have problems.

Mark


From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Marco A. Barra Montevechi Filho via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, January 9, 2023 6:44 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: Help: Asyn record getting incomplete input
 
Hello all and happy new year 🙂

We are using an IOC to control an E873 motor controller from Physik Instrumente (PI) with the gcs commands. The IOC comes from the motor-R7-1 motorPIGCS2-R1-1 module (synApps/R6.1/support/motor-R7-1/modules/motorPIGCS2-R1-1/iocs/pigcs2IOC).

We want to query some data from the controller using GCS commands that work in a common python socket script. For that we ended up setting an asyn record to the same asyn port that the motor module uses, so the st.cmd file looks something like (I append the full IOC initialization log at the end):

 drvAsynIPPortConfigure("E873_ETH","<IP>:<PORT>",0,0,0)

PI_GCS2_CreateController("E873", "E873_ETH", 1, 0, 0, 50, 1000)

dbLoadRecords("$(ASYN)/db/asynRecord.db","P=$(DEV),R=asynEth,PORT=E873_ETH,ADDR=0,OMAX=256,IMAX=520000")

Since im not trying to actually control the motor for now but just get some information from it, i didnt even load the motor records.

When the IOC is disconnected, i have a python script that does:

import socket, time
so = socket.socket()
so.connect(("CDE5B3D.abtlus.org.br",50000))
so.send("DRR?\n".encode())
time.sleep(3)
print(so.recv(2**30))

and it retrieves an enormous table, which is what i want.
Im trying to retrieve the same information from the aynPort:

dbpf MGN:A:E873:DIAG:A:asynEth.OEOS "\n"
dbpf MGN:A:E873:DIAG:A:asynEth.IFMT 2
dbpf MGN:A:E873:DIAG:A:asynEth.IEOS ""
dbpf MGN:A:E873:DIAG:A:asynEth.AOUT "DRR?
#(wait some time...)
dbgf MGN:A:E873:DIAG:A:asynEth.BINP

But i just get a small part of the table, which start right but just cuts out after some chars. It seems to always cut at 860 chars. I tried messing with IMAX but this doesnt seem to be the problem. 

Is there anything im doing wrong? Thanks in advance.

Attached file "python.txt" is table acquired with python socket. "asyn.txt" is table acquired with asyn. I noticed the acquisition is not always perfect in python too, but its far better than with asyn record.

Full IOC init log (and dbgf in .BINP made manually by me):

#!/usr/local/epics/apps/pigcs2IOC/bin/linux-x86_64/pigcs2
< /usr/local/epics/apps/pigcs2IOC/iocBoot/iocPIGCS2/envPaths
epicsEnvSet("IOC","iocPIGCS2")
epicsEnvSet("TOP","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1/modules/motorPIGCS2-R1-1/iocs/pigcs2IOC")
epicsEnvSet("SUPPORT","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support")
epicsEnvSet("ASYN","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/asyn-R4-36")
epicsEnvSet("STREAM","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/StreamDevice-2-8-9")
epicsEnvSet("CALC","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/calc-R3-7-3")
epicsEnvSet("RECCASTER","/usr/local/epics-nfs/apps/recsync/1.4_epics_3.15/client")
epicsEnvSet("SNCSEQ","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/seq-2-2-6")
epicsEnvSet("BUSY","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/busy-R1-7-2")
epicsEnvSet("IPAC","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/ipac-2-15")
epicsEnvSet("MOTOR","/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1")
epicsEnvSet("EPICS_BASE","/usr/local/epics-nfs/base/R3.15.6")
cd "/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1/modules/motorPIGCS2-R1-1/iocs/pigcs2IOC"
## Set up environment
epicsEnvSet("DEV","MGN:A:E873:DIAG:A:")
epicsEnvSet("BL", "MGN:A:E873:DIAG:A")
epicsEnvSet("IOCNAME", "MGN-A-E873A-DIAG-A")
# protocol file paths
epicsEnvSet ("STREAM_PROTOCOL_PATH", ".:/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1/db")
## Register all support components
dbLoadDatabase "dbd/pigcs2.dbd"
pigcs2_registerRecordDeviceDriver pdbbase
cd "/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1/modules/motorPIGCS2-R1-1/iocs/pigcs2IOC/iocBoot/iocPIGCS2"
## motorUtil (allstop & alldone)
dbLoadRecords("/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/motor-R7-1/db/motorUtil.db", "P=MGN:A:E873:DIAG:A:")
# PI GCS2 support
#dbLoadTemplate("/usr/local/epics/apps/config/PIGCS2/e873a.substitutions")
drvAsynIPPortConfigure("E873_ETH","CDE5B3D.abtlus.org.br:50000",0,0,0)
# Turn on asyn trace
#asynSetTraceMask("E873_ETH",0,3)
#asynSetTraceIOMask("E873_ETH",0,1)
# PI_GCS2_CreateController(portName, asynPort, numAxes, priority, stackSize, movingPollingRate, idlePollingRate)
# speedup debug
PI_GCS2_CreateController("E873", "E873_ETH", 1, 0, 0, 50, 1000)
2023/01/09 09:40:33.436 read from E873_ETH: (c)2016-2020 Physik Instrumente (PI) GmbH & Co. KG, E-873.1AT, 120040762, 03.033
PIasynAxis::PIasynAxis() 0: 1
----------------- axis num: 0 createCLParams() m_szAxisName: 1-------------------
# Turn off asyn trace
#asynSetTraceMask("E873_ETH",0,1)
#asynSetTraceIOMask("E873_ETH",0,0)
# Set end-of-string terminators (port, addr, terminator)
asynOctetSetInputEos("E873_ETH", 0, "\n")
asynOctetSetOutputEos("E873_ETH", 0, "\n")
#dbLoadRecords("$(TOP)/db/PI_Support.db","P=$(DEV),R=m1:,PORT=E873,ADDR=0,TIMEOUT=1")
# asyn record for troubleshooting
# Old IMAX in next line was 256. Might be convenient to revert value.
dbLoadRecords("/usr/local/epics-nfs/modules/R3.15.6/synApps/R6.1/support/asyn-R4-36/db/asynRecord.db","P=MGN:A:E873:DIAG:A:,R=asynEth,PORT=E873_ETH,ADDR=0,OMAX=256,IMAX=520000")
# RECSYNC
dbLoadRecords("/usr/local/epics-nfs/apps/recsync/1.4_epics_3.15/client/db/reccaster.db", "P=MGN:A:E873:DIAG:A:REC:")
iocInit
Starting iocInit
############################################################################
## EPICS R3.15.6
## EPICS Base built Sep 27 2021
############################################################################
cas warning: Configured TCP port was unavailable.
cas warning: Using dynamically assigned TCP port 41815,
cas warning: but now two or more servers share the same UDP port.
cas warning: Depending on your IP kernel this server may not be
cas warning: reachable with UDP unicast (a host's IP in EPICS_CA_ADDR_LIST)
iocRun: All initialization complete
## motorUtil (allstop & alldone)
motorUtilInit("MGN:A:E873:DIAG:A:")
# Boot complete
# fix, PI default is '\r'
dbpf "MGN:A:E873:DIAG:A:asynEth.OEOS" "\n"
DBR_STRING:          "\n"    
dbpf "MGN:A:E873:DIAG:A:asynEth.IEOS" "\n"
DBR_STRING:          "\n"    
# DEBUGGING ASYN
dbpf MGN:A:E873:DIAG:A:asynEth.IFMT 2
DBR_STRING:          "Binary"
dbpf MGN:A:E873:DIAG:A:asynEth.IEOS ""
DBR_STRING:        
dbpf MGN:A:E873:DIAG:A:asynEth.AOUT "DRR?"
DBR_STRING:          "DRR?"  
epics> 2023/01/09 09:40:39.129 PIInterface::sendAndReceive error calling writeRead, output=4 status=3, error=asynManager::queueLockPort queueRequest timed out
dbgf MGN:A:E873:DIAG:A:asynEth.BINP
epics> 2023/01/09 09:40:44.130 PIGCSController:sendAndReceive error calling write, output=POS? 1 status=3, error=asynManager::queueLockPort queueRequest timed out
dbgf MGN:A:E873:DIAG:A:asynEth.BINP
DBR_CHAR[800]:      
 "# REM E-873
#
# VERSION = 1
# TYPE = 1
# SEPARATOR = 32
# DIM = 4
# S" +
 "AMPLE_TIME = 0.00050
# NDATA = 7616
#
# NAME0 = Commanded Position of Ax" +
 "is  AXIS:1
# NAME1 = Actual Position of Axis  AXIS:1
# NAME2 = Motor Curr" +
 "ent  AXIS:1
# NAME3 = Signal Status Register of Axis  AXIS:1
#
# END_HEA" +
 "DER
-0.000001 0.000001 -0.0015 36877
-0.000001 -0.000001 -0.0015 36877
-" +
 "0.000001 -0.000001 -0.0015 36877
-0.000001 -0.000001 -0.0015 36877
-0.000" +
 "001 -0.000001 -0.0015 36877
-0.000001 0.000000 -0.0015 36877
-0.000001 0." +
 "000001 -0.0015 36877
-0.000001 -0.000001 -0.0015 36877
-0.000001 -0.00000" +
 "1 -0.0015 36877
-0.000001 -0.000001 -0.0015 36877
-0.000001 -0.000001 -0." +
 "0015 36877
-0.000001 0.000001 -0.0015 36877
-0.000001 0.000001 -0.0015 36" +
 "877
-0.000001 0.000000 -0.0015 36877
-0.000001 0"      
epics> dbpf "MGN:A:E873:DIAG:A:asynEth.AOUT" "POS? 1"
DBR_STRING:          "POS? 1"
epics> dbgf MGN:A:E873:DIAG:A:asynEth.BINP
DBR_CHAR[11]:        "1=0.000001
"

Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.

Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.


References:
Help: Asyn record getting incomplete input Marco A. Barra Montevechi Filho via Tech-talk
Re: Help: Asyn record getting incomplete input Mark Rivers via Tech-talk
Re: Help: Asyn record getting incomplete input Marco A. Barra Montevechi Filho via Tech-talk
Re: Help: Asyn record getting incomplete input Mark Rivers via Tech-talk
Re: Help: Asyn record getting incomplete input Marco A. Barra Montevechi Filho via Tech-talk
Re: Help: Asyn record getting incomplete input Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Help: Asyn record getting incomplete input Mark Rivers via Tech-talk
Next: Re: Scan rate '.01 second' not achievable Michael Davidsaver 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  <20232024 
Navigate by Thread:
Prev: Re: Help: Asyn record getting incomplete input Mark Rivers via Tech-talk
Next: asyn Sinclair, John 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  <20232024 
ANJ, 10 Jan 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·