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  <20162017  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  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: streamdevice question
From: Eric Norum <[email protected]>
To: geyang <[email protected]>
Cc: tech-talk <[email protected]>
Date: Tue, 26 Jul 2016 10:21:05 -0700
The problem here is with the client code, not the protocol.  
Something like the following might work:
import numpy as np
import struct
fNAN = struct.unpack("<f", struct.pack("<L", 0xFFFFFFFF))[0]
fArray = np.zeros(256, dtype=np.float)
fArray[0] = 1.23
fArray[1] = 3.14
for i in range(2,256): fArray[i] = fNAN
. . . send fArray . . .


You can’t just
import numpy as np
fArray = np.zeros(256, dtype=np.float)
fArray[0] = 1.23
fArray[1] = 3.14
for i in range(2,256): fArray[i] = float(‘Nan’)
since the 'unused’ bit pattern in this case is likely 0x7FC00000, not 0xFFFFFFFF.

However, if your device can actually use any ‘NAN’ value as an ‘unused’ indicator the latter example should work, too.

On Jul 26, 2016, at 9:18 AM, geyang <[email protected]> wrote:

hi,

I want to use streamdevice to communicate with a device. Each time send 256 floats (1024 bytes). The valid data part is changeable. For the rest parts will be filled with 0xffffffff (4 bytes). So I defined a waveform record like this:

record(waveform, "data")

{

  field(DTYP, "stream")

  field(SCAN, "Passive")

  field(NELM, "256")

  field(FTVL, "FLOAT")

  field(INP, "@psc.proto set_array  terminal")

}

The proto file as following:

set_array {

    MaxInput = 4;

    out "%4R";

    in "%(crc.VAL)4r"

}

Then use python to create a data list like this as the count of 0xffffffff is different each time:

[3.14,3.14, 0xffffffff,0xffffffff, 0xffffffff,0xffffffff,…],

cothread to caput the list to pv.

But the 0xffffffff will be converted to float 4294967295 and send to device as 0x4F800000 by streamdevice.

How to write the protocol file? Thanks a lot for your help.

Best wishes,
Geyang 2016/07/27



 

-- 
Eric Norum
[email protected]





References:
streamdevice question geyang

Navigate by Date:
Prev: streamdevice question geyang
Next: Re: EPICS-Arduino Serial Communication via Asyn-Stream Drivers Hulusi Öz
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: streamdevice question geyang
Next: Re: Epics-Digitizer Communication Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 28 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·