4.0 5x5 midi having trouble with sysex, dropping values on a loopback test

Status
Not open for further replies.

Oddball

Active member
built a 5x5 interface. the code is the 3x3 example with 2 more ports copy and pasted. midi note data and cc function flawlessly. this problem arose when trying to send sysex data from 3 different programs to a yamaha tx7 fm synth if it matters. I discovered what I think is at least a symptom preforming a loop test using jsynthlib on i/o ports 5-3. when sending over 91 bytes in the test it drops the same 3 characters over and over in line D and E 3F, 40, 41, anyone have any input?


XMIT: SysEX:length=111

A) 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

B) 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f

C) 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

D) 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f

E) 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

F) 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f

G) 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d f7

RECV: SysEX:length=108

A) f0 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

B) 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f

C) 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

D) 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e (3f)

E) (40)(41) 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

F) 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f

G) 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d f7

code https://github.com/OddballNo3/Midi-...y4.0/Firmware/interface_5x5/interface_5x5.ino
 
That looks like a problem with the default receive buffer size of 64 bytes (Tx default is 40). You can add extra receive and transmit buffer space to each Serial device.
Declare these globally:
Code:
#define S_BUFFER_SIZE 128
uint8_t s1RxBuffer[S_BUFFER_SIZE];
uint8_t s1TxBuffer[S_BUFFER_SIZE];
uint8_t s2RxBuffer[S_BUFFER_SIZE];
uint8_t s2TxBuffer[S_BUFFER_SIZE];
uint8_t s3RxBuffer[S_BUFFER_SIZE];
uint8_t s3TxBuffer[S_BUFFER_SIZE];
uint8_t s4RxBuffer[S_BUFFER_SIZE];
uint8_t s4TxBuffer[S_BUFFER_SIZE];
uint8_t s5RxBuffer[S_BUFFER_SIZE];
uint8_t s5TxBuffer[S_BUFFER_SIZE];

and in setup, after the serial devices are opened with .begin(), add this:
Code:
  Serial1.addMemoryForRead(s1RxBuffer,S_BUFFER_SIZE);
  Serial1.addMemoryForWrite(s1RxBuffer,S_BUFFER_SIZE);
  Serial2.addMemoryForRead(s2RxBuffer,S_BUFFER_SIZE);
  Serial2.addMemoryForWrite(s2RxBuffer,S_BUFFER_SIZE);
  Serial3.addMemoryForRead(s3RxBuffer,S_BUFFER_SIZE);
  Serial3.addMemoryForWrite(s3RxBuffer,S_BUFFER_SIZE);
  Serial4.addMemoryForRead(s4RxBuffer,S_BUFFER_SIZE);
  Serial4.addMemoryForWrite(s4RxBuffer,S_BUFFER_SIZE);
  Serial5.addMemoryForRead(s5RxBuffer,S_BUFFER_SIZE);
  Serial5.addMemoryForWrite(s5RxBuffer,S_BUFFER_SIZE);
This will add an extra 128 bytes to each Rx and Tx buffer.

Pete
 
I'm not sure I'm laying this out correctly

Code:
// Create the Serial MIDI ports
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI1);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI2);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial3, MIDI3);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial4, MIDI4);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial5, MIDI5);

// add sysex comment here

#define S_BUFFER_SIZE 128
uint8_t s1RxBuffer[S_BUFFER_SIZE];
uint8_t s1TxBuffer[S_BUFFER_SIZE];
uint8_t s2RxBuffer[S_BUFFER_SIZE];
uint8_t s2TxBuffer[S_BUFFER_SIZE];
uint8_t s3RxBuffer[S_BUFFER_SIZE];
uint8_t s3TxBuffer[S_BUFFER_SIZE];
uint8_t s4RxBuffer[S_BUFFER_SIZE];
uint8_t s4TxBuffer[S_BUFFER_SIZE];
uint8_t s5RxBuffer[S_BUFFER_SIZE];
uint8_t s5TxBuffer[S_BUFFER_SIZE];


// A variable to know how long the LED has been turned on
elapsedMillis ledOnMillis;


void setup() {
  Serial.begin(115200);
  pinMode(13, OUTPUT); // LED pin
  MIDI1.begin(MIDI_CHANNEL_OMNI);
  MIDI2.begin(MIDI_CHANNEL_OMNI);
  MIDI3.begin(MIDI_CHANNEL_OMNI);
  MIDI4.begin(MIDI_CHANNEL_OMNI);
  MIDI5.begin(MIDI_CHANNEL_OMNI);
  MIDI1.turnThruOff();
  MIDI2.turnThruOff();
  MIDI3.turnThruOff();
  MIDI4.turnThruOff();
  MIDI5.turnThruOff();

// add sysex comment here

  Serial1.addMemoryForRead(s1RxBuffer,S_BUFFER_SIZE);
  Serial1.addmemoryForWrite(s1RxBuffer,S_BUFFER_SIZE);
  Serial2.addMemoryForRead(s2RxBuffer,S_BUFFER_SIZE);
  Serial2.addMemoryForWrite(s2RxBuffer,S_BUFFER_SIZE);
  Serial3.addMemoryForRead(s3RxBuffer,S_BUFFER_SIZE);
  Serial3.addMemoryForWrite(s3RxBuffer,S_BUFFER_SIZE);
  Serial4.addMemoryForRead(s4RxBuffer,S_BUFFER_SIZE);
  Serial4.addMemoryForWrite(s4RxBuffer,S_BUFFER_SIZE);
  Serial5.addMemoryForRead(s5RxBuffer,S_BUFFER_SIZE);
  Serial5.addMemoryForWrite(s5RxBuffer,S_BUFFER_SIZE);
    
    digitalWriteFast(13, HIGH); // LED on
    delay(500);
    digitalWriteFast(13, LOW);
}
;

returns class HardwareSerial' has no member named 'addMemoryForRead .. I'm fairly new at this.. so, go easy on me :)
 
Now it doesn't compile for me either. OK, let's tackle this a different way. Unfortunately it requires editing several system files.
Each of the serial devices for Teensy 4 (I presume that's what you're using) has a file in, for example, ..\hardware\teensy\avr\cores\teensy4\HardwareSerial2.cpp which have code like this
Code:
#ifndef SERIAL2_TX_BUFFER_SIZE
#define SERIAL2_TX_BUFFER_SIZE     40 // number of outgoing bytes to buffer
#endif
#ifndef SERIAL2_RX_BUFFER_SIZE
#define SERIAL2_RX_BUFFER_SIZE     64 // number of incoming bytes to buffer
#endif
Change the RX buffer size to 128 for each of the devices you are using and see if that helps. You can also increase the TX buffer if you want.

Pete
 
ive already dug in to get rid of the 6-16 inputs from showing up.. so nothing new there lol -Fingers crossed-
 
Status
Not open for further replies.
Back
Top