\r
#include "libs/Kernel.h"\r
#include "libs/SerialMessage.h"\r
+#include "StreamOutputPool.h"\r
\r
// extern void setled(int, bool);\r
#define setled(a, b) do {} while (0)\r
\r
#define iprintf(...) do { } while (0)\r
\r
-USBSerial::USBSerial(USB *u): USBCDC(u), rxbuf(128 + 8), txbuf(128 + 8)\r
+USBSerial::USBSerial(USB *u): USBCDC(u), rxbuf(256 + 8), txbuf(128 + 8)\r
{\r
usb = u;\r
nl_in_rx = 0;\r
usb->endpointSetInterrupt(CDC_BulkOut.bEndpointAddress, true);\r
iprintf("rxbuf has room for another packet, interrupt enabled\n");\r
}\r
+ else if ((rxbuf.free() < MAX_PACKET_SIZE_EPBULK) && (nl_in_rx == 0))\r
+ {\r
+ // handle potential deadlock where a short line, and the beginning of a very long line are bundled in one usb packet\r
+ rxbuf.flush();\r
+ flush_to_nl = true;\r
+\r
+ usb->endpointSetInterrupt(CDC_BulkOut.bEndpointAddress, true);\r
+ iprintf("rxbuf has room for another packet, interrupt enabled\n");\r
+ }\r
if (nl_in_rx > 0)\r
if (c == '\n' || c == '\r')\r
nl_in_rx--;\r
if (attach)\r
{\r
attached = true;\r
- kernel->streams->append_stream(this);\r
+ THEKERNEL->streams->append_stream(this);\r
writeBlock((const uint8_t *) "Smoothie\nok\n", 12);\r
}\r
else\r
{\r
attached = false;\r
- kernel->streams->remove_stream(this);\r
+ THEKERNEL->streams->remove_stream(this);\r
txbuf.flush();\r
rxbuf.flush();\r
nl_in_rx = 0;\r
message.message = received;\r
message.stream = this;\r
iprintf("USBSerial Received: %s\n", message.message.c_str());\r
- this->kernel->call_event(ON_CONSOLE_LINE_RECEIVED, &message );\r
+ THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );\r
return;\r
}\r
else\r