Suggest Improved Python ReadFromPipeOut / WriteToPipeIn


#1

Currently accessing these methods require the use of character strings for the buffers. In most cases the data that is being transferred are byte streams, which makes the use of character strings very cumbersome and inefficient.

Adding two new pipe methods that use byte arrays would allow one to do something like the following. This would be more efficient because there’s no need to convert from byte arrays to strings and back again. Note: In the Python “C” support function PyArg_ParseTuple there is a “w#” conversion flag that can be used to handle incoming/outgoing Python byte arrays.

from array import *

To write out data - writes out 0x00,0x01,0x02,0x03

outBuf = array( ‘B’, [1,2,3,4])
xem.WriteToPipeInBytes(0x80, outBuf)

To read pipe data - reads 4 bytes of data

inBuf = array( ‘B’, [0,0,0,0])
xem.ReadFromPipeOut( 0x80, inBuf)