@@ -707,6 +707,78 @@ void radioCommandComplete(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uin
707707 waitingForCommandComplete = false;
708708}
709709
710+ int commandResponse (uint8_t * data , uint8_t length )
711+ {
712+ uint8_t * dataStart ;
713+ uint8_t * dataEnd ;
714+ VC_SERIAL_MESSAGE_HEADER * header ;
715+ int status ;
716+
717+ dataEnd = & data [length ];
718+ status = 0 ;
719+ do
720+ {
721+ dataStart = data ;
722+
723+ //Walk through the command response looking for an embedded VC message
724+ while ((data < dataEnd ) && (* data != START_OF_VC_SERIAL ))
725+ data ++ ;
726+
727+ //Output the serial data
728+ length = data - dataStart ;
729+ if (length )
730+ {
731+ status = hostToStdout (NULL , dataStart , length );
732+ if (status )
733+ break ;
734+ }
735+
736+ //Determine if there is an embedded VC message
737+ if (data >= dataEnd )
738+ break ;
739+
740+ //Verify that the entire VC message is in the buffer
741+ header = (VC_SERIAL_MESSAGE_HEADER * )data ;
742+ data ++ ; //Skip over the START_OF_VC_SERIAL byte
743+ if ((data >= dataEnd ) || (& data [* data ] > dataEnd ))
744+ {
745+ fprintf (stderr , "ERROR: VC message not fully contained in command response" );
746+ status = -20 ;
747+ break ;
748+ }
749+
750+ //Locate the VC message header and the remainder of the command response
751+ length = header -> radio .length ;
752+ dataStart = & data [VC_RADIO_HEADER_BYTES ];
753+ data += length ;
754+ length -= VC_RADIO_HEADER_BYTES ;
755+
756+ //Display the VC header and message
757+ if (DEBUG_RADIO_TO_PC )
758+ {
759+ printf ("VC Header:\n" );
760+ printf (" length: %d\n" , header -> radio .length );
761+ printf (" destVc: %d (0x%02x)\n" , (uint8_t )header -> radio .destVc , (uint8_t )header -> radio .destVc );
762+ printf (" srcVc: %d (0x%02x)\n" , header -> radio .srcVc , header -> radio .srcVc );
763+ if (length > 0 )
764+ dumpBuffer (dataStart , length );
765+ }
766+
767+ //------------------------------
768+ //Process the message
769+ //------------------------------
770+
771+ //Display radio runtime
772+ if (header -> radio .destVc == PC_RUNTIME )
773+ radioRuntime (header , dataStart , length );
774+
775+ //Dump the unknown VC message
776+ else
777+ dumpBuffer ((uint8_t * )header , length + VC_SERIAL_HEADER_BYTES );
778+ } while (data < dataEnd );
779+ return status ;
780+ }
781+
710782int radioToHost ()
711783{
712784 int bytesRead ;
@@ -811,7 +883,7 @@ int radioToHost()
811883
812884 //Display remote command response
813885 else if (header -> radio .destVc == (PC_REMOTE_RESPONSE | myVc ))
814- status = hostToStdout ( header , data , length );
886+ status = commandResponse ( data , length );
815887
816888 //Display command completion status
817889 else if (header -> radio .destVc == PC_COMMAND_COMPLETE )
0 commit comments