void radioRxHandler(rtp::packet pkt) { LOG(INF3, "radioRxHandler()"); // write packet content (including header) out to EPBULK_IN vector<uint8_t> buf; pkt.pack(&buf); // drop the packet if it's the wrong size. Thsi will need to be changed if // we have variable-sized reply packets if (buf.size() != rtp::Reverse_Size) { LOG(WARN, "Dropping packet, wrong size '%u', should be '%u'", buf.size(), rtp::Reverse_Size); return; } bool success = usbLink.writeNB(EPBULK_IN, buf.data(), buf.size(), MAX_PACKET_SIZE_EPBULK); // TODO(justin): add this message back in. For some reason, the usb system // reports failure *unless* I add a print statement inside // USBDevice.writeNB() after result = endpointWrite(). No idea why this is // the case // // if (!success) LOG(WARN, "Failed to transfer received %u byte packet over // usb", pkt.payload.size()); }
void CommModule::receive(const rtp::packet& packet) { // Check to make sure a socket for the port exists if (_ports.find(packet.port()) != _ports.end() && _ports[packet.port()].rxCallback() != nullptr) { // Allocate a block of memory for the data. rtp::packet* p = (rtp::packet*)osMailAlloc(_rxQueue, osWaitForever); // Copy the contents into the allocated memory block // TODO: move semantics *p = packet; // Place the passed packet into the rxQueue. osMailPut(_rxQueue, p); } else { LOG(WARN, "Failed to receive %u byte packet: There is no open receiving " "socket for port %u", packet.payload.size(), packet.port()); } }
void radioRxHandler(rtp::packet pkt) { LOG(INF3, "radioRxHandler()"); // write packet content (including header) out to EPBULK_IN vector<uint8_t> buf; pkt.pack(&buf); bool success = usbLink.writeNB(EPBULK_IN, buf.data(), buf.size(), MAX_PACKET_SIZE_EPBULK); // TODO(justin): add this message back in. For some reason, the usb system // reports failure *unless* I add a print statement inside // USBDevice.writeNB() after result = endpointWrite(). No idea why this is // the case // // if (!success) LOG(WARN, "Failed to transfer received %u byte packet over // usb", pkt.payload.size()); }