My apologies if this a silly question. I’ve searched and searched without any luck. Maybe my search term skills are lacking.
I want to take a stream of bytes and convert it to a stream of frames. Unfortunately there is no single “length field” in the frame. However I can calculate the frame size from four fields inside the four byte header at the start of every frame.
I tried using the variant of akka.stream.scaladsl.Framing.lengthField()
that takes a computeFrameSize
function as an argument. It seems that even though I’m providing a function to turn the 32 bits of the header into a frame size, lengthField()
takes a look at the header (which will always start with 0xFFF), says “Hey! That’s a negative number. That can’t be a valid length field.” and fails. Because the 0xFFF sync word is 12 bits long and I need the very first bit after it, I can’t simply skip over the sync word. Thus I’m always going to get a value that lengthField()
is going to interpret as a negative number.
Was it intentional for lengthField()
to make sure the field was a valid length even when provided a function to turn it into a frame length? Is there another library element that would be able to do the stream of bytes to stream of frames transformation I’m trying to do? Would the simplest solution be to just make my own framing function based on the code for lengthField()
?
Any help would be greatly appreciated.
Thanks,
-Eric