Problems with the HUSKYLENS library

Hi, I recently obtained a HuskyLens Machine Vision Sensor and am having trouble with the included library. I checked the DFRobot forum for my problem and it does exist, but the replies to those forum posts were less than useless, simply saying to try a block based coding website called mind+.

My problem is that whenever I try to verify a sketch with the huskylens library I get the following error.

In file included from C:\Users\Seth\Documents\Arduino\HuskyLens_basic\HuskyLens_basic.ino:1:0:
C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS/HUSKYLENS.h: In member function 'bool HUSKYLENS::writeFirmwareVersion(String)':
C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS/HUSKYLENS.h:706:43: error: variable-sized object 'data' may not be initialized
uint8_t data[length + 2] = {length};

This happens with the included examples and with a blank sketch with just #include "HUSKYLENS" and an empty setup and loop function.

If anyone has any insight on how to work with this library that seems kinda half finished your help would be greatly appreciated.

No link to that library!

I couldn't find your code in your post.

Hello, I am working with a sensor called a HuskyLens, I am trying to troubleshoot the library for it which has an error thrown by the arduino ide.

The error is

C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS/HUSKYLENS.h:706:43: error: variable-sized object 'data' may not be initialized
         uint8_t data[length + 2] = {length};
                                           ^

at line 706 is the following

{
        Protocol_t protocol;
        uint8_t length = version.length();
        uint8_t data[length + 2] = {length};     <--THIS IS LINE 706
        version.toCharArray((char *)data + 1, length + 1);
        protocol.firmwareVersion.length = length + 1;
        protocol.firmwareVersion.data = data;
        protocolWriteRequestFirmwareVersion(protocol);

I am not experience in library editing but it does appear that the ide thinks there is some sort of un initalized variable or bad syntax. If anyone could tell me if there is something obvious here it would be appreciated.

Here is a link to the GitHub page for the library to the header file in question.

Here is the whole error thrown by the ide.

In file included from C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS\examples\HUSKYLENS_I2C\HUSKYLENS_I2C.ino:22:0:
C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS/HUSKYLENS.h: In member function 'bool HUSKYLENS::writeFirmwareVersion(String)':
C:\Users\Seth\Documents\Arduino\libraries\HUSKYLENS/HUSKYLENS.h:706:43: error: variable-sized object 'data' may not be initialized
         uint8_t data[length + 2] = {length};
                                           ^
exit status 1
Error compiling for board Arduino Due (Programming Port).

if you make length a costant, it should work

const uint8_t length = version.length();

or, you can do the assignment after the declaration

uint8_t length = version.length();
uint8_t data[length + 2];
data[0] = length;

Thanks alot, i've still got some issues from other portions of the library, but it can compile now and thats a game changer. Would you mind if I push this to the github? The latter suggestion is what worked.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.