Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extra bytes being sent/received

 
Paul Gildea
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a terminal emulator library to create a terminal and then I use it to send the data entered over serial to a serial device. The library can be seen here: https://github.com/jackpal/Android-Terminal-Emulator/tree/master/libraries/emulatorview


When I enter data into the terminal a strange series of characters is being sent/received.

Screenshot of what appears in the terminal when i write "test":
http://i.imgur.com/Pxn2LhA.png


And the log showing the strings sent and the data received.
http://i.imgur.com/x79aPzv.png

Is there any way to fix this without parsing out characters, this might prove annoying if I actually need to type those characters!


When I type in the terminal this is run:




This is what I call to send data. sendData(Byte[] data) is a library method.

Once data is sent the reply is received here:



So it works well if I don't send if over serial, even though I can see weird bytes in the logs too, after I send them over serial and they return however they actually get written to the terminal?

Anyway to solve this without just parsing out occurrences of ~0?
 
D. Smith
Author
Greenhorn
Posts: 25
5
Android IntelliJ IDE Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the data getting from the keyboard on the device into the write() method? It looks like each character you type is getting interpreted as four bytes (perhaps cast to an int along the way?) before being passed to this method. Also, what does the sendOverSerial() method look like? Is that a method in the library you are using? I could not find GraphicsTerminalActivity in the GitHub source code.
 
Paul Gildea
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D. Smith wrote:How is the data getting from the keyboard on the device into the write() method? It looks like each character you type is getting interpreted as four bytes (perhaps cast to an int along the way?) before being passed to this method. Also, what does the sendOverSerial() method look like? Is that a method in the library you are using? I could not find GraphicsTerminalActivity in the GitHub source code.


Hi, I believe this is the class in the library that defines what happens when I type in the terminal https://github.com/jackpal/Android-Terminal-Emulator/blob/master/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java
It is getting 4 bytes as you say, but I have no idea why. sendOverserial just sends a byte array over serial, that's all, a byte array is sent back then. The data sent is already corrupted before I send it, with these extra 3 bytes. This method is from a different library. GraphicsTerminalActivity is my personal activity using the library linked in the opening post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic