Sending Binary files with C# Apps

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

I ahve been trying to send an *.elf file to a ARM controller with a custom
app written in C#. I used the BinaryReader class in order to write each btye
of the file to the serial port but it has been unsuccessful. If I send the
file with Tera Term with the binary Checkbos checked, the ARM receives the
file and everything seems to work fine!

Anyone have any advice or fixed for this problem?

Thanks
 
I assume that your binary is in format that ARM can't understand.
Maybe stopbits/databits or smth else are set wrong

Do you have a format of binary which ARM understand?
 
I have made sure that the file is in the correct format for the ARM file
by sending that file with Tera Term and it being written to the ARM's
memory correctly!

Thanks for your time and help!

--
Robert


Michael Nemtsev said:
I assume that your binary is in format that ARM can't understand.
Maybe stopbits/databits or smth else are set wrong

Do you have a format of binary which ARM understand?

--
WBR, Michael Nemtsev [.NET/C# MVP].
Blog: http://spaces.live.com/laflour



Robert said:
I ahve been trying to send an *.elf file to a ARM controller with a custom
app written in C#. I used the BinaryReader class in order to write each btye
of the file to the serial port but it has been unsuccessful. If I send the
file with Tera Term with the binary Checkbos checked, the ARM receives the
file and everything seems to work fine!

Anyone have any advice or fixed for this problem?

Thanks
 
Hello,
I have made sure that the file is in the correct format for the ARM
file by sending that file with Tera Term and it being written to the
ARM's memory correctly!

I think the idea of the previous message was about the data besides the binary
file itself — the terminal could be sending a couple commands before transmitting
the actual file, just to put the ARM into the programming mode, could that
be the case?

Also note that there are, roughly speaking, 9 bits per byte when you transmit
data over RS323, while you have only 8 in your file; was that ninth bit correct
during the communication?

The ARM might want to get some acknowledgement and a checksum at the end
of upload, as well.

(H) Serg
 
I have sent the file to a PC instead of the target having set Hyperterminal
to cature text using both tera term and my application. When I translated
them both with a binary viewer I found that my app was sending spaces as 0
instead of 32 as Tera Term was. I have not completed my testing of code I
have written to try and fix this problem but I am not optimistic of the
outcome when I do.

If more help or advice is available, I would very much like to listen!

Thanks Again!
 
I have sent the file to a PC instead of the target having set Hyperterminal
to cature text using both tera term and my application. When I translated
them both with a binary viewer I found that my app was sending spaces as 0
instead of 32 as Tera Term was. I have not completed my testing of code I
have written to try and fix this problem but I am not optimistic of the
outcome when I do.

Maybe

http://msmvps.com/blogs/coad/archiv...32-Serial-COM-Port_2900_-in-C_2300_-.NET.aspx

will help

I had some problems with reading swedish chars in files, but *hoping,
not knowing* space should not be any problem, still could be an idea
to check what your progam read from file

//CY
 
I have sent the file to a PC instead of the target having set Hyperterminal
to cature text using both tera term and my application. When I translated
them both with a binary viewer I found that my app was sending spaces as 0
instead of 32 as Tera Term was. I have not completed my testing of code I
have written to try and fix this problem but I am not optimistic of the
outcome when I do.

If more help or advice is available, I would very much like to listen!

If you're trying to send a binary file, you shouldn't be dealing with
*text* at all. Steer clear of API calls which mention string,
Encoding, or char. Stick to ones which deal with byte[] or byte.

Jon
 
As far as I know, I am only using code which deals with Byte and not strings
or charaters. I did go through all possible methods of binaryreader fro
reading and found that only readbtye or read btyes did anything for me!

Thanks!

--
Robert


Jon Skeet said:
I have sent the file to a PC instead of the target having set Hyperterminal
to cature text using both tera term and my application. When I translated
them both with a binary viewer I found that my app was sending spaces as 0
instead of 32 as Tera Term was. I have not completed my testing of code I
have written to try and fix this problem but I am not optimistic of the
outcome when I do.

If more help or advice is available, I would very much like to listen!

If you're trying to send a binary file, you shouldn't be dealing with
*text* at all. Steer clear of API calls which mention string,
Encoding, or char. Stick to ones which deal with byte[] or byte.

Jon
 
As far as I know, I am only using code which deals with Byte and not strings
or charaters. I did go through all possible methods of binaryreader fro
reading and found that only readbtye or read btyes did anything for me!

So when you wrote:

"When I translated them both with a binary viewer I found that my app
was
sending spaces as 0 instead of 32 as Tera Term was."

What did you mean, exactly? Space is a character, not a byte - if
you're dealing with pure binary stuff, the concept of "space" doesn't
exist.

Jon
 
So far I haven't been able to find an application that will let me "see" what
is excatly in the *.elf file I am sending. The best I have been able to do
is look at it with Tera Term, hyperterminal or through the Binary Viewer I
downloaded. When I say "space" I mean that Hyperterminal and Tera Term show
it as a space since they display text! When I use the Binary viewer, the
btye comes through as a 0 when my app sends that byte and when Tera Term
sends it, its a 32. I have been able to write and if statement that will
change the 0 to a 32 but that application now "hangs" up after it gets past
the 230000 byte or so. I am working on that!

I hope that helps clearify what I meant!

Thanks again for the advice, please continue to supply as much as you are
able!
 
So far I haven't been able to find an application that will let me "see" what
is excatly in the *.elf file I am sending.

Do you mean what's in the file itself? Use a binary editor such as
frhed.
The best I have been able to do
is look at it with Tera Term, hyperterminal or through the Binary Viewer I
downloaded. When I say "space" I mean that Hyperterminal and Tera Term show
it as a space since they display text! When I use the Binary viewer, the
btye comes through as a 0 when my app sends that byte and when Tera Term
sends it, its a 32.

How are you sending it in TeraTerm?
I have been able to write and if statement that will
change the 0 to a 32 but that application now "hangs" up after it gets past
the 230000 byte or so. I am working on that!

You really, really shouldn't need to start doing that. See what the
data in the file is - I strongly suspect it's a 0, and that's what you
should be sending. I suspect this part is a red herring.

Jon
 
I have been using PX Binary Viewer to see what the file is composed of and
after looking at it with frhed, the two applications seem to translate the
file the same!

To download the file using Tera Term, I get the target in the correct mode
(I know this works since I have downloaded the file this way many times!). I
select file
-->Send File and I then navigate to the *.elf file. Once I have found the
file I make sure that the "Binary" check box has been checked and click open.
Tera Term takes off and sends the file!

The "0" may not be important but I thought if I could get the two methods
(Tera Term and my App) to agree on how to send the file to my PC, maybe they
could agree on how to send it to the target!

Thanks for the ideas, please keep them coming!
 
Robert said:
I have been using PX Binary Viewer to see what the file is composed of and
after looking at it with frhed, the two applications seem to translate the
file the same!

Well, binary viewers shouldn't be doing any translation at all.
To download the file using Tera Term, I get the target in the correct mode
(I know this works since I have downloaded the file this way many times!). I
select file
-->Send File and I then navigate to the *.elf file. Once I have found the
file I make sure that the "Binary" check box has been checked and click open.
Tera Term takes off and sends the file!

If it's converting 0s to 32s, then it's doing the wrong thing. My guess
is that it's not really, but it's hard to say for sure.
 
frhed seems to work the same way PX Binary viewer does! I am not sure what
each one is doing to display the data contained in the file so I am not sure
what to do to find out whether it should be a 0 or a 32!

Thanks for the reply!
 
Robert said:
frhed seems to work the same way PX Binary viewer does! I am not sure what
each one is doing to display the data contained in the file so I am not sure
what to do to find out whether it should be a 0 or a 32!

Trust frhed and PX Binary viewer. They won't be mucking around with the
data.
 
Back
Top