Scannex ip.buffer User Manual
© UK 2007-2021 Scannex Electronics Ltd. All rights reserved worldwide.
15.3.2. Duplicating data
It may be necessary to accept data from one source channel (e.g. a serial port) and store
into two separate memory channels. The individual channels may then send the data in
two different directions to minimise the probability of data loss.
function duplicatestore(rec, chnl, tag)
mem.write(1, rec)
mem.write(2, rec)
end
x.chnl[1].src.onrecord = duplicatestore
Here, the function that is glued to the event for channel 1 will store the data into
both
channels 1 and 2. (Note that channel 2 should not be connected to another data source as
well, otherwise its data will be interleaved with the duplicate data!)
15.3.3. Discarding data
Data can be thrown away by not making a call to “mem.write”:
function discarddata(rec, chnl, tag)
-- do nothing
end
x.chnl[2].src.onrecord = discarddata
Here, data arriving at channel 2’s source will just be thrown away. Of course, you could
selectively throw the data away depending on the content of the record. In that case you
can use the Lua string functions to determine which action to take – do nothing or make a
call to “mem.write”.
Page 124
Scannex ip.buffer User Manual
© UK 2007-2021 Scannex Electronics Ltd. All rights reserved worldwide.
15.3.2. Duplicating data
It may be necessary to accept data from one source channel (e.g. a serial port) and store
into two separate memory channels. The individual channels may then send the data in
two different directions to minimise the probability of data loss.
function duplicatestore(rec, chnl, tag)
mem.write(1, rec)
mem.write(2, rec)
end
x.chnl[1].src.onrecord = duplicatestore
Here, the function that is glued to the event for channel 1 will store the data into
both
channels 1 and 2. (Note that channel 2 should not be connected to another data source as
well, otherwise its data will be interleaved with the duplicate data!)
15.3.3. Discarding data
Data can be thrown away by not making a call to “mem.write”:
function discarddata(rec, chnl, tag)
-- do nothing
end
x.chnl[2].src.onrecord = discarddata
Here, data arriving at channel 2’s source will just be thrown away. Of course, you could
selectively throw the data away depending on the content of the record. In that case you
can use the Lua string functions to determine which action to take – do nothing or make a
call to “mem.write”.
Page 124