This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes Extra bytes being sent/received Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Extra bytes being sent/received" Watch "Extra bytes being sent/received" New topic
Author

Extra bytes being sent/received

Paul Gildea
Greenhorn

Joined: Jun 30, 2009
Posts: 18
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?


^^^^ Useless at java!
D. Smith
Author
Greenhorn

Joined: Jan 11, 2013
Posts: 25
    
    5

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.


Android Recipes: A Problem Solution Approach: http://www.apress.com/9781430246145
Paul Gildea
Greenhorn

Joined: Jun 30, 2009
Posts: 18
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extra bytes being sent/received
 
Similar Threads
Pinger time!
Strip extra \r\n's in stream? Android
NX: Update Record - padding problem
Trying to Understand Java and JRE
TINIm400 module and timed reading