RE: Serial Bad Data
"Saim Ahmed" <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the responses,
Here is the code snippet from the SimpleReadWrite.java
I have solved the problem, and Jac and Bruno are correct in saying that the
PIC is sending the null characters, why another question as there is nothing
in the PIC Code that sends such data. (UART stopped when empty)
However, using the FileOutputStream class, I was able to spot the pattern in
the output file. The number of null characters is always equal to the buffer
size, and this can be looked for by looking for 0 byte entry in the buffer
array. No need to loop around the array.
byte[] readBuffer = new byte[3];
byte[] prereadBuffer = new byte[3];
int i;
try {
if(in.available() >= 3){
while (in.available() > 0) {
int numBytes = in.read(readBuffer);
}
}
if(readBuffer[0] != 0){
current_data = current_data + (new
String(readBuffer));
}
}
catch (IOException e) {
// Terminate handling this event on read error
}
Anyway, this leads me to ask why cant I get the tini to receive a burst of
20 characters from the PIC, data is always lost. I think this has been asked
here before, but never answered. The PIC is sending the data as Hyperter
reads all the characters, but the Tini doesn't, regardless of buffer size.
Any final thoughts, and thanks once again.
SAIM
-----Original Message-----
From: kersing-9+7/[email protected] [mailto:[email protected]] On Behalf Of Jac
Kersing
Sent: Friday 02 April 2004 08:52
To: Saim Ahmed
Subject: Re: [TINI]Serial Bad Data
On Fri, 2 Apr 2004, Saim Ahmed wrote:
> I have a PIC talking to the TINI 400 board (Note that the serial data
> sent is valid and checked via the Hyperterminal on a PC)
Hyperterminal does not show NULL characters AFAIK, so are you sure there
are none present???
> The problem I'm having is that the TINI is reading in NULL characters and
I
> am unaware how to remove them from my program.
I'm using TINI for binary data transfer and do not read one NULL character
(when not sending them.) Could you send a copy of your read routine so I
can look at it? (please anotate where you find the NULL characters)
Regards,
Jac
--
Jac Kersing Technical Consultant The-Box Development
j.kersing-9+7/[email protected] http://www.the-box.com
-----Original Message-----
From: Bruno De Maesschalck [mailto:bdm-RpcvRvqqnhdWk0Htik3J/[email protected]]
Sent: Friday 02 April 2004 06:57
To: Saim Ahmed
Subject: Re: [TINI]Serial Bad Data
First tought:
I think your PIC really does send the NULL characters.
Checking things like that with Hyperterminal won't get you much further,
since Hyperterminal simply doesn't show you unreadable characters.
First verify this with a serial terminal who does show all send characters,
both readible and unreadible once.
Suh terminal ofthen shows the send charactes in hex notation.
Let me know the result.
B
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini