Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No provision for a I2C bad communication or the IC not present #6

Open
stdevPavelmc opened this issue Jul 8, 2019 · 4 comments
Open
Assignees

Comments

@stdevPavelmc
Copy link
Collaborator

The library has no provision for a bad communication or even the IC not present, the sketch will simply hang and will not work.

It must has a way to alert the user that the IC in not there or even that there is no IC. In it most basic form it must not hang the full sketch for this.

@pixelwaster
Copy link

While playing with the console example, I added these lines near the end of setup()

Serial.println <the banner>
    
if ( Si.i2cRead(0) >  0 )  devicePresent = 1;  // should return the RevID=B,   -1 is missing.dead si, 

//Serial.print("Si.i2cRead(0) = "); Serial.println(Si.i2cRead(0),BIN);
//Serial.print("devicePresent = ");Serial.println(devicePresent);

if ( devicePresent == 1) { cmdHelp(); }
else {       // err msg & loop forever
   Serial.println(F("DEVICE MISSING. STOPPING.")); 
   while(1);
}

While this just warns the user and hangs, it is just the console and if the chip is not there then there is no point in continuing.
Most projects will have a display, so the user can be warned. Behavior (hang or not) should be the programmer's choice. For those without a display, a buzzer error code pattern or an LED blink pattern could be used to alert the user,

@stdevPavelmc
Copy link
Collaborator Author

Agree, I'm thinking on a function that allows the user to test the presence of the IC.

Like Si.ok(), true if present & working, and false otherwise. In this way the user can implement his own checks & warn via LED/Dispaly/Serial/whatsoever...

@croutor
Copy link

croutor commented Apr 1, 2022

Hi, thanks for your good work!
For this issue, may I suggest you to return a boolean for the 2 init methods?
If init fails, no need to go further

@stdevPavelmc
Copy link
Collaborator Author

Hi, thanks for your good work! For this issue, may I suggest you to return a boolean for the 2 init methods? If init fails, no need to go further

Yup, I think this is the way, and setup a warn code section on the example, to teach the users how to use that feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants