1

I am working with the Scribbler 2 robot and the Fluke 2 board, and communicating with the Fluke through Myro in Java. The Fluke board is a Bluetooth communication bridge between the Scribbler and the desktop client written in Java. It communicates through an RS232 serial port to the Scribbler.

This may be a dumb question and the above system is complicated, so bear with me if I don't explain this well.

The background of my question: Java uses signed bytes. The Fluke is (I think) written in C so that uses unsigned bytes. The firmware on the Scribbler is written in Spin which also uses unsigned bytes. Some of the command bytecodes for the Scribbler firmware use values that are greater than 127 so when they get sent from my Java client they are sent as negative numbers. The robot is not responding to these > 127 commands and I am trying to understand why.

The gist of my question: If I send 162 from Java it displays as -94 (seeing this in my console with 'print'). Will the Spin firmware see this as 162 because a byte is a byte, or will it see it as something else?

I know the Spin code is doing some bit shifting for params to movement commands which can be greater than 255 but it is not doing it for the specific command.

pub Move | x_coord, y_coord
'        0    1     2      3      4      5 
'Format 162 type hXByte lXByte hYByte lYByte
'  type    := indata[1]
  x_coord := (indata[2]<<8 | indata[3])
  y_coord := (indata[4]<<8 | indata[5])
spring
  • 18,009
  • 15
  • 80
  • 160
  • Tomato - do you have a version of Scribbler.java with the move() implemented, or were you implementing it yourself? I have version 1.15 of Scribbler.java and I'm about to implement the newer functions that are in Scribbler.cs - Is that what you were doing? Any tips? – Kevin S. Miller Dec 07 '14 at 02:41
  • @KevinMiller - I have v 1.1.5 – it has `void move( double translate, double rotate )` in it. Been a few years since I've looked at all that – I think I updated it to IPRE Scribbler2 Firmware v1.1.2 – spring Dec 07 '14 at 03:03
  • Tomato - Thanks for your response, but I may be confused - the Spin function "pub Move" is fired by code 162 from serial port, but 162 is never sent by Scribbler.java. The void move( double translate, double rotate ) in Scribbler.java eventually sends code 109 to the serial port. The spin move() and java move() are not related. Were you able to get the robot to move to (x,y) coordinates with a single java command? – Kevin S. Miller Dec 07 '14 at 07:43
  • @KevinMiller - been so long I can't recall. I added the ipre_s2_port.spin - IPRE Scribbler2 Firmware v1.1.2 cmds defs 161-175 to Scribber.java - (`private static final int MOVE = 162; // Format 162 type hXByte lXByte hYByte lYByte`) and was trying to get it to work when posting this question. Don't think I did. – spring Dec 07 '14 at 11:47
  • "@Tomato" - Thanks again. I need that command for a project I'm working on but time is short and I may have to find a work-around. I'll post here if I make any progress. – Kevin S. Miller Dec 08 '14 at 05:58

1 Answers1

2

Byte is 8 bits, and nothing more. It is not signed or unsigned by itself. It is arithmetic operations who make difference - simply because there are different arithmetic operations. So Java has only signed integer operations, while C has both. While a byte is sent via RS232, it does not have any operations. So don't worry, your bytes would not be spoiled by Java.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38