mBlock Arduino C compiler issue?


#1

Hi, I am trying to make an mBlock Arduino extension for a digital compass (BNO055). I uploaded all necessary resource files (headers), defined extension blocks with appropriate codes, downloaded to pc and added to extensions manager in mBlock 5. I then made a simple mBlock program to read compass calibration status using this extension. But when I try to upload the program to Arduino, it displays a large number of compiler errors. The generated C code itself is correct, because it compiles well in Arduino IDE, and runs as expected. Therefore, I suspect the C compiler in mBlock has issues? Can anyone here suggest me what the problem here is, and any workaround?

The errors are like below (some excerpt):

C:\Users\fba\mblock-avr\temp\build\src\BNO055.h:1606:12: note: each undeclared identifier is reported only once for each function it appears in ((regvar & bitnameMSK) >> bitnamePOS) ^ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:108:19: note: in expansion of macro ‘BNO055_GET_BITSLICE’ a_SWID_u8r[0] = BNO055_GET_BITSLICE(a_SWID_u8r[0],

Thank you.


#2

Could you give more of the errors or a screenshot?


#3

Sorry I truncated too much. Please see more error excerpt below. The total error message is about 14,000 words long, but most are similar. Thank you.

In file included from C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:35:0: C:\Users\fba\mblock-avr\temp\build\src\BNO055.c: In function ‘bno055_init’: C:\Users\fba\mblock-avr\temp\build\src\BNO055.h:1606:12: error: ‘bitnameMSK’ undeclared (first use in this function) ((regvar & bitnameMSK) >> bitnamePOS) ^ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:108:19: note: in expansion of macro ‘BNO055_GET_BITSLICE’ a_SWID_u8r[0] = BNO055_GET_BITSLICE(a_SWID_u8r[0], ^~~~~~~~~~~~~~~~~~~ C:\Users\fba\mblock-avr\temp\build\src\BNO055.h:1606:12: note: each undeclared identifier is reported only once for each function it appears in ((regvar & bitnameMSK) >> bitnamePOS) ^ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:108:19: note: in expansion of macro ‘BNO055_GET_BITSLICE’ a_SWID_u8r[0] = BNO055_GET_BITSLICE(a_SWID_u8r[0], ^~~~~~~~~~~~~~~~~~~ C:\Users\fba\mblock-avr\temp\build\src\BNO055.h:1606:27: error: ‘bitnamePOS’ undeclared (first use in this function); did you mean ‘bitnameMSK’? ((regvar & bitnameMSK) >> bitnamePOS) ^ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:108:19: note: in expansion of macro ‘BNO055_GET_BITSLICE’ a_SWID_u8r[0] = BNO055_GET_BITSLICE(a_SWID_u8r[0], ^~~~~~~~~~~~~~~~~~~ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c: In function ‘bno055_read_sw_revision_id’: C:\Users\fba\mblock-avr\temp\build\src\BNO055.h:1606:12: error: ‘bitnameMSK’ undeclared (first use in this function) ((regvar & bitnameMSK) >> bitnamePOS) ^ C:\Users\fba\mblock-avr\temp\build\src\BNO055.c:291:19: note: in expansion of macro ‘BNO055_GET_BITSLICE’ a_data_u8r[0] = BNO055_GET_BITSLICE(a_data_u8r[0],


#4

It looks like maybe you didn’t include all the sensor libraries properly in your extension, code, or blocks? It is still hard to tell…


#5

Thank you @Best_codes for checking my posts and replying. I think it may be an issue of C compiler built into mBlock, because the C code (generated by mBlock) compiles without any error in Arduino IDE. The mBlock compiler error messages like “‘bitnameMSK’ undeclared”, “‘bitnamePOS’ undeclared”, etc. do not make any sense. The corresponding header file content is:
#define BNO055_GET_BITSLICE(regvar, bitname)
((regvar & bitname##__MSK) >> bitname##__POS)
So, may be the pre-compiler is not working properly? Because the above code is meant to concatenate the passed parameters, but it iseems to be concatenating the parameter names instead.


#6

So what is your extension structure? Does it have the proper libraries included?

image

image


#7

I have attached the extension structure and codes below. It has 4 library files (provided by sensor maker), and 3 blocks. The 1st is command block to set up all headers, functions and definitions, and the other 2 are numerical blocks to return sensor values.


#8

I’ll see what I can find out. It looks fine to me… Give me about a week.


#9

Thank you very much!


#10

No problem!