[ECOS] about the consoles input and read from modem
xiaoyan wang
wang_xiaoyan79@yahoo.com
Sun Dec 1 22:38:00 GMT 2002
Hi,
I make the 'read' work finally. the problem is the
flags setting of POSIX. I have modified them. Any
way,Thank you for your warm help.
Best Regards
wxy
--- Chris Garry <cgarry@sweeneydesign.co.uk> wrote:
> You need a terminal emulator program (HyperTerminal
> or such like)
> running on your PC connected to you spare port on
> your target for
> input and output.
>
> As far as code goes, you need to use something like:
>
> FILE *fptr; /* Define a pointer to a
> file/stream */
> unsigned char guess;
>
> /* Open stream to serial port 1 port 1 */
> if ((fptr=fopen("/dev/ser1","r+"))==NULL)
> {
> printf("Error in opening file\n");
> exit(1);
> }
> else
> {
> /* Write message to serial port 1 */
> fprintf(fptr, "\rSerial port 1 opened
> OK\r");
> }
>
> /* Wait for space to be pressed */
> guess = '1';
> while (guess != ' ')
> fread(&guess, 1, 1, fptr);
>
> /* Get a character from the serial port */
> guess = fgetc(fptr);
>
> Basically you need to use fread() and fwrite() I
> think.
>
> Hope this helps,
> Chris
>
> ----- Original Message -----
> From: "xiaoyan wang" <wang_xiaoyan79@yahoo.com>
> To: "Chris Garry" <cgarry@sweeneydesign.co.uk>
> Cc: <ecos-discuss@sources.redhat.com>
> Sent: Wednesday, November 27, 2002 1:13 PM
> Subject: Re: [ECOS] about the consoles input and
> read from modem
>
>
> > I use one serial port for GDB, the other one for
> my GM
> > module. there is no button let me input.
> >
> > anyway, I am trying to input using the other port
> > without module just like you mentioned. I can see
> the
> > output using function write(), but whatever i
> input,
> > the read() function does not work. nothing is
> returned
> > to my processor.
> >
> > so could you tell me how to use the read()
> function to
> > get the inputting char.
> >
> > thank you very much.
> >
> > --- Chris Garry <cgarry@sweeneydesign.co.uk>
> wrote:
> > > You originally said your board has 2 serial
> ports,
> > > you could
> > > use one for the GDB connection and the other for
> > > input.
> > > You need to include the hardware device driver
> for
> > > the
> > > port you want to use for input, but not for the
> > > debug port.
> > >
> > > Failing that you can use an Ethernet port for
> your
> > > GDB
> > > connection and free up both serial ports -
> that's
> > > the way
> > > I use my board all the time. You will need to
> build
> > > a
> > > version of RedBoot with the networking enabled
> for
> > > this
> > > though.
> > >
> > > Not sure about using JTAG, I've never tried it.
> I
> > > think
> > > a search through the message archive should
> answer
> > > this
> > > question though.
> > >
> > > Chris
> > >
> > > ----- Original Message -----
> > > From: "xiaoyan wang" <wang_xiaoyan79@yahoo.com>
> > > To: "Andrew Lunn" <andrew.lunn@ascom.ch>
> > > Cc: <ecos-discuss@sources.redhat.com>
> > > Sent: Wednesday, November 27, 2002 2:24 AM
> > > Subject: [ECOS] about the consoles input and
> read
> > > from modem
> > >
> > >
> > > > Can I use JTEG or Internet to debug and use
> the
> > > serial
> > > > port to input?
> > > >
> > > > Do you know anything about the read()
> function?
> > > does
> > > > the eCos support the read() function? it is
> > > included
> > > > in unistd.h. In my application code, the
> processor
> > > can
> > > > write to but can not read from the modem.
> > > >
> > > > I used read as:
> > > > char *bufPtr;
> > > > char buffer[255];
> > > > int fd;
> > > > read(fd, bufPtr, buffer + sizeof(buffer) -
> bufPtr
> > > - 1)
> > > >
> > > > Thank you for your help.
> > > > Wxy
> > > >
> > > > --- Andrew Lunn <andrew.lunn@ascom.ch> wrote:
> > > > > You cannot use the serial port for both gdb
> and
> > > > > serial input to
> > > > > application code.
> > > > >
> > > > > You either need to use another serial port,
> or
> > > not
> > > > > use gdb. Which
> > > > > ever, use the proper serial driver, not the
> HAL
> > > diag
> > > > > driver.
> > > > >
> > > > > Andrew
> > > > >
> > > > > On Tue, Nov 26, 2002 at 05:14:36AM -0800,
> > > xiaoyan
> > > > > wang wrote:
> > > > > > Hi,
> > > > > > I am doing the programming on eCos.But now
> I
> > > need
> > > > > to
> > > > > > input something, I can not find where to
> > > input.
> > > > > The
> > > > > > consoles window can not input anything.
> > > > > >
> > > > > > i use ARM7, one serial port is for remote
> > > module,
> > > > > the
> > > > > > other is for debug. When I ran command
> > > > > arm-elf-gdb,
> > > > > > the debug window will be opened. the
> consoles
> > > > > window
> > > > > > will show the "gdb>",I just can read the
> > > "printf"
> > > > > and
> > > > > > can not use "scanf" or "getchar" to input
> > > here.
> > > > > Could
> > > > > > you tell me how to input from consoles
> window?
> > > > > >
> > > > > > Could you please kindly help me? I am very
> > > very
> > > > > > appreciated.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Best Regards
> > > > > > Wang xiaoyan
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > >
> __________________________________________________
>
=== message truncated ===
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss
mailing list