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  <20102011  2012  2013  2014  2015  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  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: asyn Driver questions
From: "Szalata, Zenon M." <[email protected]>
To: TECHTALK Tech-Talk <[email protected]>
Date: Sat, 17 Apr 2010 10:38:47 -0700
I am trying to learn how to write a driver module which is based on echoDriver.c written by Marty Kramer, which I renamed to drvMarx.c.  I have a soft IOC, which includes the drvMarx.c module and which is intended to communicate with some Ethernet device.  The network protocol is UDP.  Presently the Ethernet device is simulated with a simple Python script which receives text message, converts the text to all upper case and sends this back.  The script is working fine.

In drvMarx.c I am calling asynOctetSyncIO->readRawOnce, which fails with a timeout.  Here is the code fragment from the read routine in drvMarx.c:

printf( "\n");
printf( "mxRead:before:readRawOnce: data=%s,nbts=%d,oemReason=0x%x\n",
data,*nbytesTransfered,*eomReason);
printf( "\n");

  status=pasynOctetSyncIO->readRawOnce( pmxPvt->udpPort,0,data,maxchars,
	5,nbytesTransfered,eomReason,"");
printf( "\n");
printf( "mxRead:after:readRawOnce: data=%s,nbts=%d,oemReason=0x%x\n",
data,*nbytesTransfered,*eomReason);
printf( "\n");

This is what I have in my db file:

record( stringout, "$(P):SO:SEND:IT"){
  field( DESC, "Send msg")
  field( FLNK, "$(P):SI:READ:IT")
}
record( stringin, "$(P):SI:READ:IT"){
  field( DESC, "Read msg")
  field( DTYP, "asynOctetWriteRead")
  field( INP,  "@asyn($(P),0,1) $(P):SO:SEND:IT")
}

When I put the string Hello in the stringout record, this is what gets output:

epics> 2010/04/17 10:02:25.337 HM01 queueRequest synchronous
2010/04/17 10:02:25.337 HM01 mxDriver:write addr 0
2010/04/17 10:02:25.337 HM01 lockPort autoConnectOK 1
2010/04/17 10:02:25.337 HM01 flush
drvMarx:mxFlush
2010/04/17 10:02:25.337 HM01 mxDriver:flush addr 0
2010/04/17 10:02:25.337 HM01 mxFlush
2010/04/17 10:02:25.337 asynOctetSyncIO flush
2010/04/17 10:02:25.337 HM01 unlockPort
2010/04/17 10:02:25.337 HM01 write
Hello
2010/04/17 10:02:25.337 HM01:SI:READ:IT devAsynOctet: writeIt
Hello
2010/04/17 10:02:25.337 HM01 mxDriver:read addr 0

mxRead:before:readRawOnce: data=,nbts=0,oemReason=0x0

2010/04/17 10:02:30.338 asynOctetSyncIO readRaw failed 134.79.64.51:9999 UDP timeout: Resource temporarily unavailable

mxRead:after:readRawOnce: data=HELLO,nbts=5,oemReason=0x0

2010/04/17 10:02:30.338 mxRead nbytesTransfered 5
2010/04/17 10:02:30.338 HM01:SI:READ:IT devAsynOctet: readIt failed

Note that some of the output is generated by printf statements I put in the code.
Also note that readRawOnce returns the correct value, which means that it received the data from the python script and yet it failed.
Here is the st.cmd file:

#!../../bin/linux-x86/marx

< envPaths

cd ${TOP}

dbLoadDatabase("dbd/marx.dbd")
marx_registerRecordDeviceDriver(pdbbase)

drvAsynIPPortConfigure("HMx01","134.79.64.51:9999 UDP",0,0,0)

mxDriverInit("HM01",0,0,0,"HMx01")

dbLoadRecords("db/marx.db","P=HM01")

cd ${TOP}/iocBoot/${IOC}

asynSetTraceMask("HM01",0,0xff)
asynSetTraceIOMask("HM01",0,0x2)

iocInit()

## Start any sequence programs
#seq sncExample,"user=whitegrHost"

The big question is why is readRawOnce timing out?

Is there a document describing how to write a device specific asyn device driver?  I see examples in the asyn distribution, like the echoDriver.c, but I find it very difficult to decipher those examples.  Therefore I am stumbling around, much of the time not knowing what is the correct approach.

Thanks in advance,
Zen



Replies:
RE: asyn Driver questions Mark Rivers

Navigate by Date:
Prev: RE: Labview and EPICS on Linux Zhukov, Alexander P.
Next: RE: asyn Driver questions Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: EPICS Training Course in UK, June 7-11th Philip Taylor
Next: RE: asyn Driver questions Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·