I'm using Teensy 3.6 and all 6 Midi ports. All is working very well, except when I send a big block of messages. After about 21 messages, transmission stops. After a few milliseconds, I can send individual messages ok again, but big blocks always behave the same way. (21 messages correlates to around 64 bytes.) This seems likely to be related to transmit buffer overflow. My initial assumption was that the buffer that's overflowing is the serial buffer, so following other forum hints, I've edited the files serial1.c to serial6.c in directory "C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores", as follows. (SERIALx being replaced with SERIAL1 to SERIAL6):
#ifndef SERIALx_TX_BUFFER_SIZE
#define SERIALx_TX_BUFFER_SIZE 1024 // (old 64) number of outgoing bytes to buffer
#endif
#ifndef SERIALx_RX_BUFFER_SIZE
#define SERIALx_RX_BUFFER_SIZE 1024 // (old 64) number of incoming bytes to buffer
#endif
I've restarted the IDE and recompiled the sketch, but the behaviour is the same, and the memory usage is also the same. My questions are:
1) Is this the correct way to change the buffer sizes. If TX_BUFFER_SIZE was already defined, then won't the new value be ignored? I've tried removing the #ifndef and #endif macros, thinking this would either fix the problem or generate a duplicate symbol compile error. Neither of these things happened. (Verbose compile is turned on.)
2) Is there another "Midi Message" buffer that could be overflowing? I did see reference to a Midi Ring Queue, but I could not find any dimensioning for it.
As a workaround, I have created a midi queue within my code, and using a 1mS interrupt, dequeue any available messages and send them. This works fine, but I'm really not happy that this is right way to go.
Any suggestions welcomed.
Thanks
#ifndef SERIALx_TX_BUFFER_SIZE
#define SERIALx_TX_BUFFER_SIZE 1024 // (old 64) number of outgoing bytes to buffer
#endif
#ifndef SERIALx_RX_BUFFER_SIZE
#define SERIALx_RX_BUFFER_SIZE 1024 // (old 64) number of incoming bytes to buffer
#endif
I've restarted the IDE and recompiled the sketch, but the behaviour is the same, and the memory usage is also the same. My questions are:
1) Is this the correct way to change the buffer sizes. If TX_BUFFER_SIZE was already defined, then won't the new value be ignored? I've tried removing the #ifndef and #endif macros, thinking this would either fix the problem or generate a duplicate symbol compile error. Neither of these things happened. (Verbose compile is turned on.)
2) Is there another "Midi Message" buffer that could be overflowing? I did see reference to a Midi Ring Queue, but I could not find any dimensioning for it.
As a workaround, I have created a midi queue within my code, and using a 1mS interrupt, dequeue any available messages and send them. This works fine, but I'm really not happy that this is right way to go.
Any suggestions welcomed.
Thanks