EmbeddedRelated.com
Forums

BL4S200 Single-Board Computer - sample program for uarts, file i/o

Started by jleslie48 August 21, 2009
--- In r..., Scott Henion wrote:
>
> Jonathan Leslie wrote:
> >
> >
> > lets try this again.
> >
> > whats the difference between dynamic c's "stdio window" and a regular
> > hyper-terminal window?
> >
> > also similarly,
> >
> > lets say I load a rabbit bl4s200 with the demo1.c program so that it
> > is spits out a counter forever to stdout.
> >
> > Now lets say I take the rabbit bl4s200 to a different PC that does not
> > have dynamic C loaded onto it. How do view the output of the demo1.c
> > program? The second PC doesn't have a "stdio window" as the target
> > for the rabbits stdout. All the second PC has is hyperterminal to
> > talk to com ports.
> >
> look at the defines in stdio.lib:
>
> // for debugging, stdion can be redirected to a serial port
> // uncomment the following 3 defines to use this.
> #define STDIO_DEBUG_SERIAL SADR
> #define STDIO_DEBUG_BAUD 115200
> #define STDIO_DEBUG_ADDCR
>
> Then it will output debug info on the programming port. You will need to
> use the "Diag" connector not the "Prog" connector on the programming cable.
>
> If you have one of the newer programming cables with just one connector,
> you are screwed on this. You can redirect the info to another serial
> port with the defines though.

Thank you for the information, but it not a complete solution.
Can you relate this answer back to my question?

You have now added the concept of stdion.

what is the relationship between "stdion", "the stdio window",
the three "#define"'s you listed from stdio.lib, and what I really want, an output to a STANDARD comm port?

I want to use the STANDARD part of stdio. This does not include Rabbits custom "diag" connector, "prog" connector, or "programming port". I just want a program that outputs info on a STANDARD RS232 comm port, aka, RX,TX on pins 2,3 of a DB9 in the right voltage or at least ttl that I can level shift. I should be able to hook up this DB9 to any old PC's comm port and run hyper-terminal and when I set matching baud rates, see my datastream.
jleslie48 wrote:
> --- In r..., Scott Henion wrote:
>
>> Jonathan Leslie wrote:
>>
>>> lets try this again.
>>>
>>> whats the difference between dynamic c's "stdio window" and a regular
>>> hyper-terminal window?
>>>
>>> also similarly,
>>>
>>> lets say I load a rabbit bl4s200 with the demo1.c program so that it
>>> is spits out a counter forever to stdout.
>>>
>>> Now lets say I take the rabbit bl4s200 to a different PC that does not
>>> have dynamic C loaded onto it. How do view the output of the demo1.c
>>> program? The second PC doesn't have a "stdio window" as the target
>>> for the rabbits stdout. All the second PC has is hyperterminal to
>>> talk to com ports.
>>>
>>>
>> look at the defines in stdio.lib:
>>
>> // for debugging, stdion can be redirected to a serial port
>> // uncomment the following 3 defines to use this.
>> #define STDIO_DEBUG_SERIAL SADR
>> #define STDIO_DEBUG_BAUD 115200
>> #define STDIO_DEBUG_ADDCR
>>
>> Then it will output debug info on the programming port. You will need to
>> use the "Diag" connector not the "Prog" connector on the programming cable.
>>
>> If you have one of the newer programming cables with just one connector,
>> you are screwed on this. You can redirect the info to another serial
>> port with the defines though.
>>
>
> Thank you for the information, but it not a complete solution.
> Can you relate this answer back to my question?
>
> You have now added the concept of stdion.
>
> what is the relationship between "stdion", "the stdio window",
> the three "#define"'s you listed from stdio.lib, and what I really want, an output to a STANDARD comm port?
>
> I want to use the STANDARD part of stdio. This does not include Rabbits custom "diag" connector, "prog" connector, or "programming port". I just want a program that outputs info on a STANDARD RS232 comm port, aka, RX,TX on pins 2,3 of a DB9 in the right voltage or at least ttl that I can level shift. I should be able to hook up this DB9 to any old PC's comm port and run hyper-terminal and when I set matching baud rates, see my datastream.
>

First of all DC does not have a true stdio implemented. There is no FILE
* support for streams or things like fwrite(), fprintf() etc. Softools
has true stdio support so you can do things like: _stdio=SerialB; to
assign stdio to a serial port.

For DC use the defines I described and change the define:

#define STDIO_DEBUG_SERIAL SADR

To SBDR for port B, SCDR for port C etc.
------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------

today's fortune
I was part of that strange race of people aptly described as spending
their lives doing things they detest to make money they don't want to
buy things they don't need to impress people they dislike.
-- Emile Henry Gauvreay
The stdio window is essentially a debugging tool. If you read the example code you ran, DC uses printf to write to stdio, just like in C. If you don't connect to serial port A, you don't see any output.

I'm not familiar with that exact board, or DC10, but I assume that DC10 still includes RS232.LIB, which allows you to read and write the serial ports. Somewhere in the examples you will find code using the serial ports.

You need to get familiar with the board's I/O options and decide what serial port you want to use, then select the lib functions that access the port you want to use. Unless the board comes with the connectors you want, you will have to work out some adapters to connect to a serial port on a PC.
Mark