Anyway we will do a small debug test…
For that you will need to recompile the MBNG app after modification…
in mbng_file_c.c at line 812
replace this:
//////////////////////////////////////////////////////////////////////////////////////////////// } else if( strcasecmp(parameter, "nrpn") == 0 ) { int value; if( (value=get\_dec(value\_str)) \< 0 || value \>= 16384 ) { #if DEBUG\_VERBOSE\_LEVEL \>= 1 DEBUG\_MSG("[MBNG\_FILE\_C:%d] ERROR: invalid NRPN number in EVENT\_%s ... %s=%s\n", line, event, parameter, value\_str); #endif return -1; } else { if( item.flags.type != MBNG\_EVENT\_TYPE\_NRPN ) { #if DEBUG\_VERBOSE\_LEVEL \>= 1 DEBUG\_MSG("[MBNG\_FILE\_C:%d] WARNING: no NRPN number expected for EVENT\_%s due to type: %s\n", line, event, MBNG\_EVENT\_ItemTypeStrGet(&item)); #endif } else { // no extra check if event\_type already defined... stream[1] = value & 0xff; stream[2] = value \>\> 8; item.secondary\_value = stream[1]; } } ////////////////////////////////////////////////////////////////////////////////////////////////
by
//////////////////////////////////////////////////////////////////////////////////////////////// } else if( strcasecmp(parameter, "nrpn") == 0 ) { int value; if( (value=get\_dec(value\_str)) \< 0 || value \>= 16384 ) { #if DEBUG\_VERBOSE\_LEVEL \>= 1 DEBUG\_MSG("[MBNG\_FILE\_C:%d] ERROR: invalid NRPN number in EVENT\_%s ... %s=%s\n", line, event, parameter, value\_str); #endif return -1; } else { if( item.flags.type != MBNG\_EVENT\_TYPE\_NRPN ) { #if DEBUG\_VERBOSE\_LEVEL \>= 1 DEBUG\_MSG("[MBNG\_FILE\_C:%d] WARNING: no NRPN number expected for EVENT\_%s due to type: %s\n", line, event, MBNG\_EVENT\_ItemTypeStrGet(&item)); #endif } else { // no extra check if event\_type already defined... stream[1] = value & 0x7f; stream[2] = value \>\> 7; item.secondary\_value = stream[1]; } } ////////////////////////////////////////////////////////////////////////////////////////////////
Cause !
In this part of the parser there’s something strange which is disturbing me at the end when the address is store in the item->stream we’ve got:
// no extra check if event\_type already defined... stream[1] = value & 0xff; stream[2] = value \>\> 8; item.secondary\_value = stream[1];
but in the MBNG_EVENT_TYPE_NRPN part of the MBNG_EVENT_ItemSend function we’ve got:
u16 nrpn\_address = item-\>stream[1] | ((u16)item-\>stream[2] \<\< 7);
if I make the calculation like it is I find exactly your problem:
In parser
stream[1] = 261 & 0xff = 5
stream[2] = 261 >> 8 = 1
then in MBNG_EVENT_ItemSend
u16 nrpn_address = item->stream[1] | ((u16)item->stream[2] << 7) = 5 | (1<<7) = 133
Address msb is not limited to 0 or 1, I think it’s a masking and shifting error and bit 7 is lost, so make the test with
// no extra check if event\_type already defined... stream[1] = value & 0x7f; stream[2] = value \>\> 7; item.secondary\_value = stream[1];
Please