OK, I have decided to take the bull by the horns, and make a personal firmware for the Shruthi-1 that will allow me to fix the incompatibility with the checksum in SoundDiver which I use as an editor for it.
SoundDiver allows for a nibbelized checksum that goes LH, which is opposite of Shruthi’s HL checksum, so I thought it might be best to simply change the firmware, so that it simply swap the transmitted and recieved checksum nibbles.
I’ve set up the toolchain, and I can now compile .hex/.syx/.mid firmware files, so the only thing missing is changing the code itself in the firmware.
But to be honest, this C (or C+/++ whatever) is totaly new to me, having only worked with PIC assembly code, so I’ve been fooling around with the Shruthi code, to see if I can find and decipher the correct code to change, and would like to know if I’m going in the right direction.
In the code file “storage.cc” I’ve found what I believe to be the code to change (?)… in two places… and they are as follows for sending sysex dumps:
@
/* static */
void Storage::SysExDumpBuffer(
uint8_t* data,
uint8_t command,
uint8_t argument,
uint8_t size) {
Serial<MidiPort, 31250, DISABLED, POLLED> midi_output;
// Outputs the SysEx header.
for (uint8_t i = 0; i < sizeof(sysex_rx_header); ++i) {
midi_output.Write(pgm_read_byte(sysex_rx_header + i));
}
midi_output.Write(command);
midi_output.Write(argument);
uint8_t checksum = 0;
for (uint8_t i = 0; i < size; ++i) {
checksum += data[i];
midi_output.Write(U8ShiftRight4(data[i]));
midi_output.Write(data[i] & 0x0f);
}
- midi_output.Write(U8ShiftRight4(checksum));
- midi_output.Write(checksum & 0x0f);
midi_output.Write(0xf7); //
}
@
Now, I asume that to swap the two nibbles being send out as checksum in a sysex dump, that the two lines that I’ve marked with an * has to be swapped in possition?
And now the recieving part:
@ case RECEIVING_DATA:
{
uint16_t i = sysex_rx_bytes_received_ >> 1;
if (sysex_rx_bytes_received_ & 1) {
- sysex_rx_destination_[i] |= sysex_rx_byte & 0xf;
if (i < sysex_rx_expected_size_) {
sysex_rx_checksum_ += sysex_rx_destination_[i];
}
} else { - sysex_rx_destination_[i] = U8ShiftLeft4(sysex_rx_byte);
}
sysex_rx_bytes_received_**;
if (sysex_rx_bytes_received_ >= (1 + sysex_rx_expected_size_) * 2) {
sysex_rx_state_ = RECEIVING_FOOTER;
}
}
break;@
I suppose that here, the two lines marked with * is the ones to swap?
I hope that you (Pichenettes) can confirm this, or at least guide me in the right direction if I’m wrong?
Regards.