-
Notifications
You must be signed in to change notification settings - Fork 0
Update pi4j and address api changes #329
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be tested. Will be really evident if the rov works or not lol. Trail and error is the name of this game
@@ -156,9 +162,12 @@ private short getPosition() { | |||
lock.lock(); | |||
try { | |||
serial.write(new byte[] {START_BYTE, maestro, COMMAND_GET_POSITION, channel}); | |||
final ByteBuffer response = ByteBuffer.allocate(4).putChar(serial.read()).putChar(serial.read()); | |||
final ByteBuffer response = ByteBuffer.allocate(4).put(serial.read(), 0, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like different logic. You only have one serial read.
putChar
also writes two bytes into the buffer.
This seems weird in the first place. We could maybe jut write:
return ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN).put(
new byte[]{serial.read(), serial.read()}).getShort(0);
try { | ||
serial.write(new byte[] {START_BYTE, maestro, COMMAND_GET_ERRORS}); | ||
final ByteBuffer response = ByteBuffer.allocate(2).put(serial.read(), 0, 2); | ||
return BitSet.valueOf(new byte[]{response.get(1), response.get(0)}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again seems weird
e5a823e
to
535b443
Compare
On second thought, the byte reads don't even matter because we don't use the voltage or current sensor |
We have to update pi4j to fix #328. Doing so has broken some of our code, mostly catching new exceptions when using serial.
@cal-pratt check the changes to MaestroChannel closely because I might have screwed up your byte management. serial.read() returns a byte array instead of a char now.