I should also mention that you should check the return from pasynOctetSyncIO->readIt and perform the sscanf only on asynSuccess -- and perform the callbacks only when the sscanf succeeds….
On Apr 2, 2012, at 12:33 PM, Eric Norum wrote:
> The example shown is for a device that produces a message on request.
>
> In your case the device sends unsolicited messages so your plan to invoke readIt rather than writeRead is correct. You would then not need the epicsThreadSleep -- just make sure that the timeout specified in the readIt invocation is longer than the expected time between hardware triggers.
> If you've interposed the EOS processing module the readIt routine will not return until timeout or receipt of the end-of-string character.
>
> On Apr 2, 2012, at 12:16 PM, Fong, Nia W. wrote:
>
>> Hi,
>>
>> I'd like to use asynPortDriver to connect to a serial device that pushes data when triggered by a hardware pulse.
>>
>> If I use SCAN=I/O Intr and the pollThread() example code below from a previous tech-talk thread will my record be triggered to read every time there is new data? Does this code mean my driver is constantly polling the serial port at a POLL_DELAY?
>>
>> I only need to read, so can I call pasynOctetSyncIO->readIt() instead?
>>
>> How will I know that the serial device has finished pushing it's data for that trigger? Does asyn/pasynOctetSynIO->readIt() wait for the OutputEos in the serial buffer before returning the received message? Or is asyn waiting to read sizeof(receiveMessage) characters?
>>
>>
>>> void myPortDriver::pollThread()
>>> {
>>> while(1) {
>>> status = pasynOctetSyncIO->writeRead(pasynUserHMS, sendMessage, numSend,
>>> receiveMessage, sizeof(receiveMessage),
>>> WRITE_READ_TIMEOUT, &numSent, responseLen, &eomReason);
>>> sscanf(receiveMessage, "TEMP=%f,CURRENT=%f", &temperature, ¤t);
>>> setDoubleParam(temperatureParam, temperature);
>>> setDoubleParam(currentParam, current);
>>> callParamCallbacks();
>>> epicsThreadSleep(POLL_DELAY);
>>> }
>>> }
>>>
>>
>>
>> Thank you in advance for any suggestions or comments.
>>
>> Nia
>
> --
> Eric Norum
> [email protected]
>
>
>
>
--
Eric Norum
[email protected]
- References:
- asyn w/serial device pushing data Fong, Nia W.
- Re: asyn w/serial device pushing data Eric Norum
- Navigate by Date:
- Prev:
Re: asyn w/serial device pushing data Eric Norum
- Next:
RE: asyn w/serial device pushing data Mark Rivers
- 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
- Navigate by Thread:
- Prev:
Re: asyn w/serial device pushing data Eric Norum
- Next:
RE: asyn w/serial device pushing data Mark Rivers
- 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
|