I'm trying to use the CFDP plugin. This is the streamsql file I was recommended to use:
create stream cfdp_in as select substring(packet, 6) as pdu from tm_realtime where extract_short(packet, 0) = 6141
create stream cfdp_out (gentime TIMESTAMP, entityId long, seqNum int, pdu binary)
insert into tc_realtime select gentime, 'cfdp-service' as origin, seqNum, '/yamcs/cfdp/upload' as cmdName, unhex('17FDC0000000') + pdu as binary from cfdp_out
However, this is making several assumptions that may be application prohibitive, and I would like to try to submit the fix myself.
1) This is assuming the outgoing stream is CCSDS, and this specifies that there is no secondary header. In my case, my remote entity requires a secondary header, but that shouldn't be a problem. My secondary command header is fixed anyway, so that's an easy one to include in this sql query.
2) The primary header includes message length, but this sets that field to 0. This would still work if the remote entity ignores the length field. What I would like to do is basically:
unhex('17FDC000') + size(pdu) + pdu <-- Basically generate a 4 byte padded size field
I don't know how to get the size of the binary type. Does the streamsql API have a method to do this, or do I need to add an expression?
Furthermore, is this really the best solution anyway? Or should I create a plugin that takes messages from one stream, sticks a primary and secondary header on it, and writes it to the realtime stream? Basically do this in code, rather than in a streamsql. What's the best solution?