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  <20142015  2016  2017  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  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Changing the Timeout for drvAsynSerialPort?
From: Mark Rivers <[email protected]>
To: "'Eric Norum'" <[email protected]>, Franklin Fuller <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Thu, 11 Dec 2014 18:29:52 +0000

In general it’s a better idea to add the termination commands using asynOctetSetOutputEos than using the Terminator command in the StreamDevice protocol file.  That way if you change from using serial to using TCP/IP you only need to change your startup script, not your protocol file.

 

Mark

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of Eric Norum
Sent: Thursday, December 11, 2014 12:27 PM
To: Franklin Fuller
Cc: [email protected]
Subject: Re: Changing the Timeout for drvAsynSerialPort?

 

I suspect that you need to add a terminator to the command.

At the top of your protocol file add:

 

 

Terminator = ‘\n’;

 

 

Here’s the section of the manual describing the variables:

 

5. Protocol Variables

StreamDevice uses three types of variables in a protocol file. System variables influence the behavior of in and out commandsProtocol arguments work like function arguments and can be specified in the INP or OUT link of the record. User variables can be defined and used in the protocol as abbreviations for often used values.

System and user variables can be set in the global context of the protocol file or locally inside protocols. When set globally, a variable keeps its value until overwritten. When set locally, a variable is valid inside the protocol only. To set a variable use the syntax:
variable = value;

Set variables can be referenced outside of quoted strings by $variable or ${variable} and inside quoted strings by \$variable or \${variable}. The reference will be replaced by the value of the variable at this point.

System variables

This is a list of system variables, their default settings and what they influence.

LockTimeout = 5000;

Integer. Affects first out command in a protocol.
If other records currently use the device, how many milliseconds to wait for exclusive access to the device before giving up?

WriteTimeout = 100;

Integer. Affects out commands.
If we have access to the device but output cannot be written immediately, how many milliseconds to wait before giving up?

ReplyTimeout = 1000;

Integer. Affects in commands.
Different devices need different times to calculate a reply and start sending it. How many milliseconds to wait for the first byte of the input from the device? Since several other records may be waiting to access the device during this time, 
LockTimeout should be larger than ReplyTimeout.

ReadTimeout = 100;

Integer. Affects in commands.
The device may send input in pieces (e.g. bytes). When it stops sending, how many milliseconds to wait for more input bytes before giving up? If 
InTerminator = "", a read timeout is not an error but a valid input termination.

PollPeriod = $ReplyTimeout;

Integer. Affects first in command in I/O Intr mode (see chapter Record Processing).
In that mode, some buses require periodic polling to get asynchronous input if no other record executes an 
in command at the moment. How many milliseconds to wait after last poll or last received input before polling again? If not set the same value as for ReplyTimeout is used.

Terminator

String. Affects out and in commands.
Most devices send and expect terminators after each message, e.g. 
CR LF. The value of the Terminator variable is automatically appended to any output. It is also used to find the end of input. It is removed before the input is passed to the in command. If no Terminator or InTerminatoris defined, the underlying driver may use its own terminator settings. For example, asynDriver defines its own terminator settings.

OutTerminator = $Terminator;

String. Affects out commands.
If a device has different terminators for input and output, use this for the output terminator.

InTerminator = $Terminator;

String. Affects in commands.
If a device has different terminators for input and output, use this for the input terminator. If no 
Terminator or InTerminator is defined, the underlying driver may use its own terminator settings. If InTerminator = "", a read timeout is not an error but a valid input termination.

MaxInput = 0;

Integer. Affects in commands.
Some devices don't send terminators but always send a fixed message size. How many bytes to read before terminating input even without input terminator or read timeout? The value 
0 means "infinite".

Separator = "";

String. Affects out and in commands.
When formatting or parsing array values in a format converter (see formats and waveform record), what string to write or to expect between values? If the first character of the 
Separator is a space, it matches any number of any whitespace characters in an in command. To match arbitrary amount of whitespace in input, use "\_".

ExtraInput = Error;

Error or Ignore. Affects in commands.
Normally, when input parsing has completed, any bytes left in the input are treated as parse error. If extra input bytes should be ignored, set 
ExtraInput = Ignore;

 

 

 

 

On Dec 11, 2014, at 10:16 AM, Franklin Fuller <[email protected]> wrote:

 

Mark,

 

I added those environment variables, trace outputs, fixed a missing parenthesis in the original st.cmd, and then recompiled before running.  I also disabled the firewall on this mac laptop, just in case that was causing problems.  Here now is the output:

 

#!../../bin/darwin-x86/ps365controlTest

##########################################

# Setup Environment

< envPaths

epicsEnvSet("ARCH","darwin-x86")

epicsEnvSet("IOC","iocps365controlTest")

epicsEnvSet("TOP","/Users/fdfuller/src/EPICS/myapps/ps365control")

epicsEnvSet("ASYN","/Users/fdfuller/src/EPICS/modules/asyn")

epicsEnvSet("STREAM","/Users/fdfuller/src/EPICS/modules/streams")

epicsEnvSet("EPICS_BASE","/Users/fdfuller/src/EPICS/base")

epicsEnvSet "STREAM_PROTOCOL_PATH" "/Users/fdfuller/src/EPICS/myapps/ps365control/db"

##########################################

# Allow PV prefixes and serial port name to be set from the environment

epicsEnvSet "P" "ps365control"

epicsEnvSet "R" "Test"

epicsEnvSet "TTY" "/dev/cu.usbserial-FTWDR32T"

##########################################

# Register all support components

cd /Users/fdfuller/src/EPICS/myapps/ps365control

dbLoadDatabase(dbd/ps365controlTest.dbd)

ps365controlTest_registerRecordDeviceDriver(pdbbase)

##########################################

# Set up ASYN ports

drvAsynSerialPortConfigure("L0","/dev/cu.usbserial-FTWDR32T",0,0,0) #sets up a port L0 at $TTY (see above)

#now we fill in the details of the port connection

#9600/8/N/1 is the most typical serial port configuration

asynSetOption("L0",0,"baud","9600")

asynSetOption("L0",0,"bits","8")

asynSetOption("L0",0,"parity","none")

asynSetOption("L0",0,"stop","1")

asynSetTraceIOMask("L0",0,2)

asynSetTraceMask("L0",0,255)

##########################################

## Load record instances

dbLoadRecords("db/devps365control.db","P=ps365control,R=Test,PORT=L0,A=0")

##########################################

# Start EPICS

cd /Users/fdfuller/src/EPICS/myapps/ps365control/iocBoot/iocps365controlTest

iocInit

Starting iocInit

############################################################################

## EPICS R3.14.12.4 $Date: Mon 2013-12-16 15:51:45 -0600$

## EPICS Base built Sep 21 2014

############################################################################

2014/12/11 09:46:01.492 L0 addr -1 queueRequest priority 0 not lockHolder

2014/12/11 09:46:01.493 L0 schedule queueRequest timeout

2014/12/11 09:46:01.493 asynManager::portThread port=L0 callback

2014/12/11 09:46:01.493 L0 addr -1 queueRequest priority 0 not lockHolder

2014/12/11 09:46:01.493 L0 schedule queueRequest timeout

2014/12/11 09:46:01.493 L0 addr -1 queueRequest priority 0 not lockHolder

2014/12/11 09:46:01.493 L0 schedule queueRequest timeout

2014/12/11 09:46:01.493 asynManager::portThread port=L0 callback

2014/12/11 09:46:01.493 /dev/cu.usbserial-FTWDR32T read.

2014/12/11 09:46:01.493 /dev/cu.usbserial-FTWDR32T read 0, return 1

2014/12/11 09:46:01.493 /dev/cu.usbserial-FTWDR32T write.

2014/12/11 09:46:01.493 /dev/cu.usbserial-FTWDR32T write 5

*IDN?

cas warning: Configured TCP port was unavailable.

cas warning: Using dynamically assigned TCP port 49730,

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)

2014/12/11 09:46:01.494 wrote 5 to /dev/cu.usbserial-FTWDR32T, return asynSuccess

2014/12/11 09:46:01.494 L0 wrote

*IDN?

2014/12/11 09:46:01.494 L0 addr -1 queueRequest priority 0 from lockHolder

2014/12/11 09:46:01.494 L0 schedule queueRequest timeout

2014/12/11 09:46:01.494 asynManager::portThread port=L0 callback

2014/12/11 09:46:01.494 /dev/cu.usbserial-FTWDR32T read.

iocRun: All initialization complete

epics> 2014/12/11 09:46:02.489 /dev/cu.usbserial-FTWDR32T timeout handler.

2014/12/11 09:46:02.594 /dev/cu.usbserial-FTWDR32T read 0, return 1

2014/12/11 09:46:02.594534 L0 ps365controlTestIDN: No reply from device within 1000 ms

2014/12/11 09:46:02.595 asynManager::portThread port=L0 callback

2014/12/11 09:46:02.595 L0 addr -1 queueRequest priority 0 not lockHolder

2014/12/11 09:46:02.595 L0 schedule queueRequest timeout

2014/12/11 09:46:02.595 asynManager::portThread port=L0 callback

2014/12/11 09:46:02.595 /dev/cu.usbserial-FTWDR32T read.

2014/12/11 09:46:02.595 /dev/cu.usbserial-FTWDR32T read 0, return 1

2014/12/11 09:46:02.595 /dev/cu.usbserial-FTWDR32T write.

2014/12/11 09:46:02.595 /dev/cu.usbserial-FTWDR32T write 5

*IDN?

2014/12/11 09:46:02.595 wrote 5 to /dev/cu.usbserial-FTWDR32T, return asynSuccess

2014/12/11 09:46:02.595 L0 wrote

*IDN?

2014/12/11 09:46:02.595 L0 addr -1 queueRequest priority 0 from lockHolder

2014/12/11 09:46:02.595 L0 schedule queueRequest timeout

2014/12/11 09:46:02.595 asynManager::portThread port=L0 callback

2014/12/11 09:46:02.595 /dev/cu.usbserial-FTWDR32T read.

2014/12/11 09:46:03.591 /dev/cu.usbserial-FTWDR32T timeout handler.

2014/12/11 09:46:03.695 /dev/cu.usbserial-FTWDR32T read 0, return 1

2014/12/11 09:46:03.695444 L0 ps365controlTestIDNwf: No reply from device within 1000 ms

 

 

So the upshot is that it looks like it's doing something.  The downside is: I don't know why it isn't receiving a response.  As I said, if you manually send values to /dev/cu.usbserial-FTWDR32T, such as the *IDN? command that it's trying, you get a response.  I tested other commands and full control is possible.

 

Still reading this streamDevice documentation to figure out where I can add some communication timeout time.  Not sure that's the issue anymore, now that I see this trace output.

 

-- 
Eric Norum
[email protected]

 


Replies:
Re: Changing the Timeout for drvAsynSerialPort? Eric Norum
References:
Changing the Timeout for drvAsynSerialPort? Franklin Fuller
RE: Changing the Timeout for drvAsynSerialPort? Mark Rivers
Re: Changing the Timeout for drvAsynSerialPort? Franklin Fuller
Re: Changing the Timeout for drvAsynSerialPort? Eric Norum

Navigate by Date:
Prev: RE: Changing the Timeout for drvAsynSerialPort? Mark Rivers
Next: Re: Changing the Timeout for drvAsynSerialPort? Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Changing the Timeout for drvAsynSerialPort? Eric Norum
Next: Re: Changing the Timeout for drvAsynSerialPort? Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·