Help coderanch get a
new server
by contributing to the fundraiser

Paul Gildea

Greenhorn
+ Follow
since Jun 30, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
7
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Gildea

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.
11 years ago
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?
11 years ago
I fixed the doubt prompt issue (stopped sending \r) now but the original problem is not actually fixed.

When I used your code it stopped the spaces, but now when I enter text from the terminal itself and hit enter...no new line appears. It must be because the \n is ignored after the \r.
11 years ago

Steve Luke wrote:When you are counting the number of CRs you could peak ahead at the next byte, and if it is '\n' don't count it:


Then do something similar when you are copying in the '\r\n' into the results.

On the other hand, Android is a Linux box, and you only need to use '\n'. Perhaps you should simply append '\n' to the TextView (not '\r\n'), and perhaps just replaces any '\r' you find in the write() method with '\n' (maybe with a peak ahead to see if the next character is a '\n' and if it is do nothing)



Thanks a lot Luke I got it working with the help of your code, no more weird spaces, just the one extra newline somewhere as I get the prompt back twice like this after I send a command:

Switch#
Switch#


So i have an erroneous newline somewhere hmm!
11 years ago

Kemal Sokolovic wrote:Please CarefullyChooseOneForum. I have moved a thread to Android forum.


Just had it in java as it is java code in particular that is the problem, not the android API.
Thank you, won't make the mistake again
11 years ago
I am trying to connect to a terminal emulator using a library in android, this will connect to a serial device and should show me sent/received data. I should be able to send data over the connection via a text box below the terminal or by typing in the terminal itself and hitting enter on the keyboard in both cases.

When I was sending data via textbox I had to append \r\n to the data to get to a new line when I pressed the enter key like so:


And the write method:


With this I got the prompt back twice from the terminal, which is wrong. When I was hitting enter after typing in the terminal session itself no new line was occurring at all. So I had to test the data for \r and replace it with \r\n


So that worked fine, now when I type in the terminal session itself and hit enter i got the newline I wanted. However now every time I send data from the text box with with \r\n there is an extra space between every new line as well as getting the extra newline. I assume \r\n is getting translated to \r\n\n and I'm not sure why I am getting the extra space between every line, so how do i change the code so that both ways of entering text generate the correct result?

Issues here are that as well as after I send data and am getting the terminal prompt back twice in all cases, for some reason I also get a space between every line. If I go back to the original write function I don't get the erroneous spaces but I get the prompt twice and typing in the terminal session itself does not work, no new line.

Original terminal getting prompt twice sending data from a text box, and when I write via terminal itself I don't get any new line.



Here is what the badly formatted terminal with the new write looks like, extra spaces, getting prompt twice when data is sent:

11 years ago
Did you have to pay for it twice?

Roel De Nijs wrote:Moved to the more appropriate forum.

I don't think there are already books on the market especially for this certification. I have done a technical review of a book for this certification, so I know publishers are working on them And I can say that if you use K&B6 and stick to the objectives for this certifications you'll have a great resource.



Thanks, I guess I will stick with that so. And jsut keep an eye out for exams.

Roel De Nijs wrote:Paul,

Will you go for OCAJ 5/6 or OCAJ 7? Because there is a huge difference between these certifications (although both Associate) in required knowledge.

Kind regards,
Roel



Sorry for omitting this information Roel, 5/6 seem quite rudimentary, so I will be going for 7 as that seems about half as hard as the SCJP 6 was, and am looking for material related to that.

Shalini Srivastav wrote:

I don't find anything cheaper than enthuware,give a try.



Looks good, thanks.

Shalini Srivastav wrote:www.coderanch.com/t/570259/java-SCJA/certification/Java-OCA



Thank you, that is the book and sticky I have already read.

I am just looking for additional sources. I looked at the FAQ and the free exams don't appear to be free, so I would like to find some mock ones, if any are available.
Hello, I was studying for the OCPJP 6 and I have the Sierra & Bates book which I have gone through once. I'm on a second pass now.
However I have decided to go for the OCA instead. 1Z0-803 and then 1Z0-804, OCPJP. Can anybody recommend study material apart from the book that I already have?
I have read the sticky on this forum and realize what is relevant from this book.

Also where are there mock exams? Preferably free ones.

Thank you.

Amrish Jhaveri wrote:Fees of OCJP 6 exam has changed from $300 to $150, right??

Where did you see this?

It's 238 euro in Ireland...
I graduated from my masters 1.5 years ago and have not worked since, I went travelling. Since I have never worked I will be looking for a graduate role. I think getting the ocjp 6 now would help, and help get me back in touch with programming. I have a big gap on my CV with me doing 'nothing' for the last 1.5 years which I believe looks bad. Thanks for the info, sounds like I will learn more by going with 1/2. ocpjp 6 will help me better with 7 if I wish to upgrade also.

What was your primary goal? To learn?

Haha nice answer, I will go with OCJP 6 so!
Thank you, I will read that forum also.

If you had to choose one exam OCA 7 or OCPJP 6 which would you do? Which would look nicer on a cv or teach you more?