UDP Byte in Serial Byte out

Discussion to talk about software related topics only.
Post Reply
leifkrinkle
Posts: 2
Joined: Wed May 12, 2010 9:44 am

UDP Byte in Serial Byte out

Post by leifkrinkle »

I am trying to do a simple thru-put.
I know I am sending a single byte via udp to my SB72, but printing that byte to the serial port seems to be problematic.
I have tried using ShowData(upkt.GetDataBuffer(), len); but this converts the byte to ascii
I have tried using write(fdserial,(const char *) upkt.GetDataBuffer(), len ), which seems to print the appropriate byte from 32 to 127 , but not the appropriate byte < 32 or > 127.
What I would like to see is a byte from 0 to 255 be sent via UDP directly written to the serial port.
Am I casting the byte improperly? Is there a function that prints just bytes, not ascii, or chars?

Thanks,
Leif Krinkle
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: UDP Byte in Serial Byte out

Post by rnixon »

What are you using on the serial side to "view" the data? Is it capable of displaying binary data in binary form? The ranges you provided for what you say works corresponds to printable/non-printable characters.
leifkrinkle
Posts: 2
Joined: Wed May 12, 2010 9:44 am

Re: UDP Byte in Serial Byte out

Post by leifkrinkle »

I am using zterm and Max/MSP
With ShowData(upkt.GetDataBuffer(), len); when I send a UDP byte I get the appropriate byte out serial but represented in ascii hex
with write(fdserial,(const char *) upkt.GetDataBuffer(), len ); I send a UDP byte and get the exact byte back out of serial from 32 to 127, but anything <32 or >127 i receive a binary 46 out of serial.

I am only slightly modifying the udp example found in C:\nburn\examples\udp\SimpleUDPToSerial

is there a function that outputs a byte out of serial?
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: UDP Byte in Serial Byte out

Post by Chris Ruff »

It is not normal for a terminal program to show you the data without altering it. I use Viewcomm (o-o-o-old) in DOS mode to see the actual data. I also have used XTALK.EXE (o-o-o-o-o-o-o-o-old) and put it into debug mode to see the binary values

It is normal for all terminal programs to make binary data 'readable'

PCs also like to eat 0 and 0xff chars as well
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: UDP Byte in Serial Byte out

Post by rnixon »

My first suspect is zterm is messing with non-printable data, so its not your netburner code. You can verify this with a scope. The chars zterm is not "printing" are terminal control codes, such as 0x07 for beep, etc.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: UDP Byte in Serial Byte out

Post by tod »

I have had good luck on the NetBurner family with just using:

Code: Select all

cout << some_binary_value + 0x0;
I'm not sure why I have to add the +0x0 but it doesn't work without it and it works with it.

It would probably be more portable to do something like:

Code: Select all

char some_char = static_cast<char>(some_binary_value +0); //maybe the +0 isn't needed but would require testing
cout << some_char;
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: UDP Byte in Serial Byte out

Post by Ridgeglider »

you might also look at a terminal program called indigo http://www.shadeblue.com/products/indigo/
It has modes where it displays ascii, hex, binary, control codes. You can also set it up to color code key phrases that a NB module might be spewing out so you can see them easily. It also has a much longer buffer than MTTTY and I've found it less subject to MTTTY's (rare) quirky lockups. It costs $25, but works well. Note that it gets locked to a specific PC, maybe w/ the hard disk,or MAC, but they will allow you to deregister and move it...
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: UDP Byte in Serial Byte out

Post by Chris Ruff »

:lol: :lol: :lol:

A node-locked twenty-five dollar terminal program

:lol: :lol: :lol:

Some Nerve!
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
PJE
Posts: 1
Joined: Thu Apr 24, 2008 4:51 pm

Re: UDP Byte in Serial Byte out

Post by PJE »

Chris Ruff wrote::lol: :lol: :lol:

A node-locked twenty-five dollar terminal program

:lol: :lol: :lol:

Some Nerve!
It's also the serial terminal I've used for a number of years. It has saved me much more than I spent on it in saved time and effort.

Given it's capabilities, I feel $25 is good value. There have been a couple of occasions when I had to use another terminal app for a specific purpose, but Shade Blue Indigo is my default terminal app.
Post Reply