Hello,

I'm successfully using and TANGO pipe to write a binary bitstream to a device server using a DeviceProxy in C++, but I'm having trouble getting the equivalent code to work in Python.

Here is the working C++ code that writes an DevULong size followed by a number of DevVarCharArrays.


fpga = new DeviceProxy( "some/tango/device" );

ifstream bitfile(argv[1], std::ios::binary | std::ios::ate );
if( bitfile.good() ) {
uint32_t size = bitfile.tellg();
bitfile.seekg(0, std::ios::beg);

DevicePipe bsize;
bsize.set_name("bitstream");
vector<std::string> blobnames {"bitstreamInfo"};
bsize.set_data_elt_names(blobnames);
bsize << size;
fpga->write_pipe(bsize);
cout << "Bitstream size is " << size << " bytes." << endl;

for( unsigned i = 0; i < size; i += sendSize ) {
unsigned bufSize = (i+sendSize > size) ? size-i : sendSize;

DevVarCharArray *buf = new DevVarCharArray();
buf->length(bufSize);
if( bitfile.read(reinterpret_cast<char*>(buf->get_buffer()), bufSize) ) {
DevicePipe bdata;
bdata.set_name("bitstream");
bdata.set_data_elt_names(blobnames);
bdata << buf;
fpga->write_pipe(bdata);
cout << "Sent " << bufSize << " bytes" << endl;
}
else {
cout << "Error while reading in bitstream file" << endl;
}
}

}


In PyTango, I can't get the first write_pipe() to work where I write a single DevULong value.
Is there something wrong with how I'm assembling that 'blob' variable for write_pipe input argument? Are there any exmaples of write_pipe() usage out there I can follow?


blob = ("bitstream", ("bitstreamInfo", {"dtype":CmdArgType.DevULong, "value":fileSize}))
DeviceProxy.write_pipe(blob)

Traceback (most recent call last):
File "C:\test\util_loadBitstream.py", line 44, in <module>
DeviceProxy.write_pipe(blob)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tango\green.py", line 195, in greener
return executor.run(fn, args, kwargs, wait=wait, timeout=timeout)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tango\green.py", line 109, in run
return fn(*args, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\tango\device_proxy.py", line 1481, in __DeviceProxy__write_pipe
pipe_name, (blob_name, blob_data) = args
ValueError: not enough values to unpack (expected 2, got 0)


Thanks in advance for your help.

Mike