Too few input values to make output type
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm reading a binary stream from a serial port. The binary stream looks like this:
start byte (actually byte series)
length of subsequent data
important data
checksum
The stream is coming from a QUARC block, 16 bytes at a time. So, I'm put this into a MATLAB function that uses persistent variables to process the stream, detect the sync sequence, grab the length byte, and then read the next x bytes. The last 8 bytes (which is a float) is the checksum.
I want to convert that byte stream into a float, and then I can determine from the important data if it matches.
I've successfully used typecast to do this, but in this case it's simply not working.
I suspect, because the other complication, is that this is being built for code generation.
So, to provide specific details:
'bytes' is read in, and determined to be 48 bytes. the 40-48 bytes is the checksum. But I'm not always guaranteed to read in 48 bytes. I'd like to have some flexibility, so I cannot guarantee the size of the bytes that I am going to read (based on what I am sending, which is why I am sending the length)
So, 'bytes' (variable) now contains the length of the data, including the 8-byte checksum.
so, I try to type case that:
checksum = typecast(uint8(data(bytes-7:bytes)), 'double');
And it seems that it's not going to work when I build it.
"Too few input values to make output type.
Function 'Subsystem/MATLAB Function3' (#59.1056.1084), line 56, column 19:
"typecast(uint8(d), 'double')"
Launch diagnostic report."
If I hard code in some values:
checksum = typecast(uint8(data(32-7:32)), 'double');
The application builds fine.
I've been banging my head at reading this byte stream for far too long, and I finally made some progress and now hit another wall. Any thoughts are welcome.
5 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!