Hi Joao,
The example in asyn/testAsynPortDriver is a simple example.
This tutorial starts with a simple driver and gets more complex in subsequent versions:
https://github.com/epics-modules/measComp/blob/master/documentation/measCompTutorial.pdf
This page has links to 2015 YouTube video lectures on asyn and asynPortDriver:
https://epics.anl.gov/docs/APS2015.php
This page also has links to 2018 YouTube videos on asyn and asynPortDriver under the areaDetector section:
https://www.bnl.gov/ps/epics/
Mark
Thank you for the quick answer.
I will take a look into asynPortDriver documentation, to see if writing a driver is a good approach for us.
Is there any specific documentation you would recommend to help writing it?
Hi Joao,
What you have tried seems reasonable, but unfortunately it won’t work. The reason is that the drvAsynIPPort driver does not have a mechanism to asynchronously call
back to device support when new input arrives. There are several other ways to do this.
-
You can use streamDevice. It works with SCAN=I/O Intr records by polling the device. streamDevice should even be able to parse the UDP buffer for you into the individual records
you want to use.
-
You could write your own little asyn driver, derived from asynPortDriver. It would just have a small loop like this:
while (1) {
pasynOctet->read(myBuffer)
value1 = parseMyBuffer(1)
setIntegerParam(myParam1, value1)
value2 = parseMyBuffer(2)
setIntegerParam(myParam2, value2)
callParamCallbacks()
}
Mark
First, sorry if any of these questions seems too simple. I started working recently with EPICS and I am still learning how it works.
Basically, I am trying to create an IOC that works as a UDP server. It should be listening at a certain port and, when a new packet arrives, it should update a set
of records with the incoming data.
It doesn't need to respond to any of the packets.
The data is a binary array, which will be read into a waveform record, and then unpacked into other records in order to be read by the clients (I don't know if this
is the best approach, for now I am just experimenting). The structure of the binary array is fixed and known beforehand.
For now, I just want to update the waveform record with the binary data when the UDP packet arrives. I am using asynDriver since it seems to provide all the tools
I need:
On the 'st.cmd' file I have:
drvAsynIPServerPortConfigure ("fgc_udp", "localhost:2906 udp", 10, 0, 0, 0)
dbLoadRecords("db/fgc_udp.db","GW=${FGC_GW_NAME}:")
And on the 'db/fgc_udp.db' I have:
record(waveform, "$(GW)UDP") {
field(SCAN, "I/O Intr")
field(DTYP, "asynOctetRead")
field(FTVL, "UCHAR")
field(DESC, "UDP publication")
field(NELM, "4096")
field(INP, "@asyn(fgc_udp, 0, 0) drvUser")
}
Since I am using 'I/O Intr', I would expect the record to be updated when a new UDP packet arrives, but it is not working.
It only updates if I use the IOC shell command "dbtr xxx:UDP", or if I change SCAN to a "N seconds" option.
Do you know how I can fix it? I guess it is something simple, but I am stuck.
I would also like to know if using a waveform record is a good starting point for unpacking binary data, or if there is a better alternative.
|