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

Mock plugin single byte read returns -1 for 0xff. #164

Closed
gugrim opened this issue Nov 26, 2021 · 0 comments · Fixed by #165
Closed

Mock plugin single byte read returns -1 for 0xff. #164

gugrim opened this issue Nov 26, 2021 · 0 comments · Fixed by #165
Assignees
Labels
bug Something isn't working

Comments

@gugrim
Copy link
Contributor

gugrim commented Nov 26, 2021

The single byte read method in MockI2C returns an unmasked byte as its int result, i e
return b;
instead of
return b & 0xff;

Byte values from 0x80 to 0xff are returned as negative ints making it impossible to test for EOF.

Diff:
`diff --git a/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/i2c/MockI2C.java b/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/i2c/MockI2C.java
index f161576..bfad59a 100644
--- a/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/i2c/MockI2C.java
+++ b/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/i2c/MockI2C.java
@@ -155,7 +155,7 @@ public class MockI2C extends I2CBase implements I2C {
logger.info("] :: READ(0x");
logger.info(StringUtil.toHexString(b));
logger.info(")");

  •    return b;
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants