Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
273 stars 57 forks source link

Unexpected PI_BAD_HANDLE #360

Closed SSNC-SushilBohaju closed 4 months ago

SSNC-SushilBohaju commented 4 months ago

When i close the program, I got the strange error code : PIGPIO ERROR: PI_BAD_HANDLE; unknown handle Does anyone know the error on pi4j V2.

taartspi commented 4 months ago

To try and help more information is needed. Please provide more details. Pi model, SNAPSHOT used, java version, and the stack trace. With those someone may have insight to the cause of your exception.

SSNC-SushilBohaju commented 4 months ago

image [Uploading hs_err_pid1565.log…]()

SSNC-SushilBohaju commented 4 months ago

To try and help more information is needed. Please provide more details. Pi model, SNAPSHOT used, java version, and the stack trace. With those someone may have insight to the cause of your exception.

Err_SnsrCtlApp_20240521.log

taartspi commented 4 months ago
  1. Are you using Remote Pigpio to execute your code, does the entire program execute on your Pi4
  2. Did the program function correctly until you tried to close the program
  3. Looks like the upload hs_err_pid1565.log was not successful
  4. line 1081 shows the pi4j context is already shutdown, which makes sense as you said you closed the program. But the next line 'getGridFeedInOutPowerModbus' implies you still have some portion of the program functioning(maybe a separate thread) . Is there code still running and it is creating these error messages ?
taartspi commented 4 months ago

And the error message, most if not all Pigpio I2C functions can return this Error_Code. Something as simple as you closed the device by it going out of scope, and then attempted to read or write from the same device, using a stale handle

SSNC-SushilBohaju commented 4 months ago
  1. Are you using Remote Pigpio to execute your code, does the entire program execute on your Pi4
  2. Did the program function correctly until you tried to close the program
  3. Looks like the upload hs_err_pid1565.log was not successful
  4. line 1081 shows the pi4j context is already shutdown, which makes sense as you said you closed the program. But the next line 'getGridFeedInOutPowerModbus' implies you still have some portion of the program functioning(maybe a separate thread) . Is there code still running and it is creating these error messages ?

All program running inside rpi When i close program using cltr+c image After 1081 line the following logs are generate after re execute the program you can check with time frame Its just a warning but it make my err log difficult for read so i am looking from where this warn log are printing

taartspi commented 4 months ago

that NOT INITIALIZED error, if you program was successfully reading from your I2C device prior to ctrlC I again ask if you have some thread still running after you ctrlC your program. At any rate. The logs yesterday look like some code is repeatedly accessing an I2C device, so I think you need to just use the debugger, set a break point for any of your I2C calls and make sure they are working and see when they begin to fail.

SSNC-SushilBohaju commented 4 months ago

that NOT INITIALIZED error, if you program was successfully reading from your I2C device prior to ctrlC I again ask if you have some thread still running after you ctrlC your program. At any rate. The logs yesterday look like some code is repeatedly accessing an I2C device, so I think you need to just use the debugger, set a break point for any of your I2C calls and make sure they are working and see when they begin to fail.

Thank you for your help .... problem is solved. :)

taartspi commented 4 months ago

Glad you solved it. Tom