Skip to content

Commit ab4841e

Browse files
author
Craig Versek
committed
fixed major BUG with using _input_len for output buffer
1 parent 77dc410 commit ab4841e

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

PacketCommand.cpp

+35-35
Original file line numberDiff line numberDiff line change
@@ -590,17 +590,17 @@ PacketShared::STATUS PacketCommand::send(bool& sentPacket){
590590
DEBUG_PORT.println(timestamp_micros);
591591
#endif
592592
if (_send_callback != NULL){
593-
set_sendTimestamp(timestamp_micros); //markdown the time write now
594-
if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
595-
if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
596-
pack_uint32(timestamp_micros);
597-
}
598-
else{
599-
#ifdef PACKETCOMMAND_DEBUG
600-
DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
601-
#endif
602-
}
603-
}
593+
// set_sendTimestamp(timestamp_micros); //markdown the time write now
594+
// if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
595+
// if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
596+
// pack_uint32(timestamp_micros);
597+
// }
598+
// else{
599+
// #ifdef PACKETCOMMAND_DEBUG
600+
// DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
601+
// #endif
602+
// }
603+
// }
604604
//call the callback!
605605
sentPacket = (*_send_callback)(*this);
606606
return PacketShared::SUCCESS;
@@ -622,17 +622,17 @@ PacketShared::STATUS PacketCommand::send_nonblocking(){
622622
DEBUG_PORT.println(timestamp_micros);
623623
#endif
624624
if (_send_nonblocking_callback != NULL){
625-
set_sendTimestamp(timestamp_micros); //markdown the time write now
626-
if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
627-
if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
628-
pack_uint32(timestamp_micros);
629-
}
630-
else{
631-
#ifdef PACKETCOMMAND_DEBUG
632-
DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
633-
#endif
634-
}
635-
}
625+
// set_sendTimestamp(timestamp_micros); //markdown the time write now
626+
// if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
627+
// if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
628+
// pack_uint32(timestamp_micros);
629+
// }
630+
// else{
631+
// #ifdef PACKETCOMMAND_DEBUG
632+
// DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
633+
// #endif
634+
// }
635+
// }
636636
//call the nonblocking send callback
637637
(*_send_nonblocking_callback)(*this);
638638
return PacketShared::SUCCESS;
@@ -649,17 +649,17 @@ PacketShared::STATUS PacketCommand::send_nonblocking(){
649649
PacketShared::STATUS PacketCommand::send_buffered(){
650650
uint32_t timestamp_micros = micros();
651651
if (_send_buffered_callback != NULL){
652-
set_sendTimestamp(timestamp_micros); //markdown the time write now
653-
if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
654-
if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
655-
pack_uint32(timestamp_micros);
656-
}
657-
else{
658-
#ifdef PACKETCOMMAND_DEBUG
659-
DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
660-
#endif
661-
}
662-
}
652+
// set_sendTimestamp(timestamp_micros); //markdown the time write now
653+
// if (_output_flags & PacketShared::OPFLAG_APPEND_SEND_TIMESTAMP){
654+
// if ((_output_len + sizeof(uint32_t)) < PacketShared::DATA_BUFFER_SIZE){ //prevent buffer overrun
655+
// pack_uint32(timestamp_micros);
656+
// }
657+
// else{
658+
// #ifdef PACKETCOMMAND_DEBUG
659+
// DEBUG_PORT.println(F("### Error: appending send timestamp would overrun the output buffer"));
660+
// #endif
661+
// }
662+
// }
663663
//call the nonblocking send callback
664664
(*_send_buffered_callback)(*this);
665665
return PacketShared::SUCCESS;
@@ -780,7 +780,7 @@ void PacketCommand::resetInputBuffer(){
780780

781781
PacketShared::STATUS PacketCommand::enqueueInputBuffer(PacketQueue& pq){
782782
#ifdef PACKETCOMMAND_DEBUG
783-
//DEBUG_PORT.println(F("# In PacketCommand::enqueueInputBuffer"));
783+
DEBUG_PORT.println(F("# In PacketCommand::enqueueInputBuffer"));
784784
#endif
785785
//build a packet struct to hold current buffer state
786786
PacketShared::Packet pkt;
@@ -894,7 +894,7 @@ PacketShared::STATUS PacketCommand::dequeueOutputBuffer(PacketQueue& pq){
894894
_output_len = min(pkt.length, _outputBufferSize);
895895
_output_index = _output_len; //IMPORTANT! set output index end of last entry so stuff could be added properly
896896
_output_flags = pkt.flags;
897-
memcpy(_output_buffer, pkt.data, _input_len);
897+
memcpy(_output_buffer, pkt.data, _output_len);
898898
return PacketShared::SUCCESS;
899899
}
900900
else{

PacketQueue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ PacketShared::STATUS PacketQueue::enqueue(PacketShared::Packet& pkt)
100100
PacketShared::STATUS PacketQueue::dequeue(PacketShared::Packet& pkt)
101101
{
102102
#ifdef PACKETQUEUE_DEBUG
103-
DEBUG_PORT.println(F("# In PacketQueue::dequeue"));
103+
//DEBUG_PORT.println(F("# In PacketQueue::dequeue"));
104104
#endif
105105
if (_size > 0){
106106
_get_from(_beg_index, pkt);
@@ -116,7 +116,7 @@ PacketShared::STATUS PacketQueue::dequeue(PacketShared::Packet& pkt)
116116
}
117117
else{
118118
#ifdef PACKETQUEUE_DEBUG
119-
DEBUG_PORT.println(F("### Error: Queue Underflow"));
119+
//DEBUG_PORT.println(F("### Error: Queue Underflow"));
120120
#endif
121121
pkt.length = 0; //set to safe value
122122
return PacketShared::ERROR_QUEUE_UNDERFLOW;

0 commit comments

Comments
 (0)