public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] cyg_io_read
@ 2009-04-20 12:01 grahamlab
  0 siblings, 0 replies; 10+ messages in thread
From: grahamlab @ 2009-04-20 12:01 UTC (permalink / raw)
  To: ecos-discuss


Hello all
I am having trouble understanding the operation of the cyg_io_read
operation.
I have a simple programto read the /dev/ser1 device on my stm3120e dev
board.
If i set blocking on read then my cyg_io_read call only returns when the
specified number of bytes has been received -

char msg[10]
cyg_uint32 msglen=10;
res = cyg_io_read(handle,msg,&msglen); // returns when 10 bytes have been
received.

However, I want to read bytes as they arrive. With this in mind I set the
device to operate in non blocking mode -
block = 0;
len = sizeof(cyg_uint32);
cyg_io_set_config(handle,CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING,&block,&len);

I set up my code to ignore EAGAIN errors on the read -
    while(1)
    {
    	char msg[10];
    	cyg_uint32 msglen=10;

    	res = cyg_io_read(handle,msg,&msglen);
    	if (res != -EAGAIN)
    	{
    		diag_printf ("read %d %d\n",res,msglen);
    		for (cyg_uint32 x = 0; x < msglen; ++x)
    		{
    			diag_printf("%c",msg[x]);
    		}
    		diag_printf("\n\n");
    	}

With this in place I expected to receive all bytes sent by the sending
program , BUT NO
I only receive the first 2 or three. If I send single characters I get these
but if I send anything more I dont get what I sent.

I would be grateful if someone could explain this behavior.

Thanks Graham

-- 
View this message in context: http://www.nabble.com/cyg_io_read-tp23134401p23134401.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] cyg_io_read
  2005-03-15 13:34 baljeet singh
  2005-03-15 14:21 ` Gary Thomas
@ 2005-03-16  4:24 ` Marco SICHERI [CTS]
  1 sibling, 0 replies; 10+ messages in thread
From: Marco SICHERI [CTS] @ 2005-03-16  4:24 UTC (permalink / raw)
  To: baljeet singh; +Cc: eCos Discus.List, eCos Dev.List

Hi Baljeet,
I do this...
Good work!

//
// ----- 
CPSUARTGetChar -----------------------------------------------------
//
BYTE CPSUARTGetChar(BYTE uartID, BYTE *charD)
{
 BYTE rc = CPSRC_OK;

 //
 // Controllo uart valida e pronta
 //
 rc = _CTSUARTCheckUartReady(uartID);
 if (rc == CPSRC_UART_NOTREADY)
 {
  //
  // Aprire la uart
  //
  rc = _CTSUARTOpenUart(uartID);
 }

 //
 // Porta pronta, controlliamo i dati!
 //
 if (rc == CPSRC_OK)
 {
  if (cyg_io_select(ctsUartHandle[uartID], CYG_FREAD, uartInfo) == false)
   return (CPSRC_UART_NOTREADY);
  else
  {
   cyg_uint32 dataToRead = 1;
   if (cyg_io_read(ctsUartHandle[uartID], &charD[0], &dataToRead))
    return (CPSRC_UART_NOTREADY);
  }
 }

 return (rc);
}

Ossequi,  (Best Regards/Obrigado)
Marco SICHERI
CTS electronics  - R&D Department
phone: +39 0125 235637, +39 0125 235630
e-mail: m.sicheri@ctsgroup.it
http://www.ctsgroup.it


----- Original Message ----- 
From: "baljeet singh" <baljeet45@yahoo.com>
To: <ecos-discuss@sources.redhat.com>
Sent: Tuesday, March 15, 2005 4:36 AM
Subject: [ECOS] cyg_io_read


> All,
> one of the parameters in the cyg_io_read(..) is
> the number of bytes to read. Process blocks till
> specified number of bytes have been read. If the
> specified number of bytes is not received, the
> process stays blocked.
> Question: Is there a way to block the process for
> a specified amount of time such that the prcoess
> should return on either receiving the specified
> number of bytes or when the specified delay times
> out?
> Baljeet
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] cyg_io_read
  2005-03-15 13:34 baljeet singh
@ 2005-03-15 14:21 ` Gary Thomas
  2005-03-16  4:24 ` Marco SICHERI [CTS]
  1 sibling, 0 replies; 10+ messages in thread
From: Gary Thomas @ 2005-03-15 14:21 UTC (permalink / raw)
  To: baljeet singh; +Cc: eCos Discussion

On Mon, 2005-03-14 at 19:36 -0800, baljeet singh wrote:
> All,
> one of the parameters in the cyg_io_read(..) is
> the number of bytes to read. Process blocks till
> specified number of bytes have been read. If the
> specified number of bytes is not received, the
> process stays blocked.
> Question: Is there a way to block the process for
> a specified amount of time such that the prcoess
> should return on either receiving the specified
> number of bytes or when the specified delay times
> out?

Use a higher level of I/O (file I/O package -> open, close,
etc).  Then you can use select with timeouts.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ECOS] cyg_io_read
@ 2005-03-15 13:34 baljeet singh
  2005-03-15 14:21 ` Gary Thomas
  2005-03-16  4:24 ` Marco SICHERI [CTS]
  0 siblings, 2 replies; 10+ messages in thread
From: baljeet singh @ 2005-03-15 13:34 UTC (permalink / raw)
  To: ecos-discuss

All,
one of the parameters in the cyg_io_read(..) is
the number of bytes to read. Process blocks till
specified number of bytes have been read. If the
specified number of bytes is not received, the
process stays blocked.
Question: Is there a way to block the process for
a specified amount of time such that the prcoess
should return on either receiving the specified
number of bytes or when the specified delay times
out?
Baljeet


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] cyg_io_read
  2000-08-23  6:23       ` Eric Fradette
@ 2000-08-23  8:06         ` Jesper Skov
  0 siblings, 0 replies; 10+ messages in thread
From: Jesper Skov @ 2000-08-23  8:06 UTC (permalink / raw)
  To: Eric Fradette; +Cc: Ecos-Discuss

>>>>> "Eric" == Eric Fradette <emf8@po.cwru.edu> writes:

Eric> sorry, i meant to typ /dev/ser0 as you said.  That is actually
Eric> what I am using.


No idea, then. Sorry. Fire up GDB and see what's happening (assuming
you have a spare serial line).

Jesper

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] cyg_io_read
  2000-08-23  6:18     ` Jesper Skov
@ 2000-08-23  6:23       ` Eric Fradette
  2000-08-23  8:06         ` Jesper Skov
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Fradette @ 2000-08-23  6:23 UTC (permalink / raw)
  To: Jesper Skov; +Cc: Ecos-Discuss

sorry, i meant to typ /dev/ser0 as you said.  That is actually what I am
using.
>
> [Please make sure to CC the discuss list in the future]
>
> >>>>> "Eric" == Eric Fradette <emf8@po.cwru.edu> writes:
>
> Eric> Actually I am using /dev/tty/ser0.  It doesn't seem to work
> Eric> whether I give it a buffer with an actual length, or if I loop
> Eric> it to take in one character at a time it never will take
> Eric> anything past a 0x0.
>
> /dev/tty/ser0??!  Well, it's been a while since I've been around that
> code, but the 'tty' part of that string suggests tty console
> behavior. Try /dev/ser0 as I suggested in the previous mail. when you
> are reading binary date.
>
> Jesper
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] cyg_io_read
       [not found]   ` <NEBBLBCPCLNPKNANBKIKOEPLCBAA.emf8@po.cwru.edu>
@ 2000-08-23  6:18     ` Jesper Skov
  2000-08-23  6:23       ` Eric Fradette
  0 siblings, 1 reply; 10+ messages in thread
From: Jesper Skov @ 2000-08-23  6:18 UTC (permalink / raw)
  To: ecos-discuss; +Cc: Eric Fradette

[Please make sure to CC the discuss list in the future]

>>>>> "Eric" == Eric Fradette <emf8@po.cwru.edu> writes:

Eric> Actually I am using /dev/tty/ser0.  It doesn't seem to work
Eric> whether I give it a buffer with an actual length, or if I loop
Eric> it to take in one character at a time it never will take
Eric> anything past a 0x0.

/dev/tty/ser0??!  Well, it's been a while since I've been around that
code, but the 'tty' part of that string suggests tty console
behavior. Try /dev/ser0 as I suggested in the previous mail. when you
are reading binary date.

Jesper

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] cyg_io_read
  2000-08-22 13:11 Eric Fradette
@ 2000-08-23  5:57 ` Jesper Skov
       [not found]   ` <NEBBLBCPCLNPKNANBKIKOEPLCBAA.emf8@po.cwru.edu>
  0 siblings, 1 reply; 10+ messages in thread
From: Jesper Skov @ 2000-08-23  5:57 UTC (permalink / raw)
  To: Eric Fradette; +Cc: Ecos-Discuss

>>>>> "Eric" == Eric Fradette <emf8@po.cwru.edu> writes:

Eric> Hi, I am using the function cyg_io_read() with AEB-1, and am
Eric> running into a problem in that it appears that cyg_io_read()
Eric> returns when it encounters 0x0 (the ASCII NUL character).  Is
Eric> this correct?  If it is, how can I keep it from doing this since
Eric> that is part of that data that I need.  Or, is there some
Eric> cyg_io_getc type of function that will retun the character no
Eric> matter what it is.

Which device are you reading from? /dev/ttyX by any chance? Try the
raw device /dev/serX instead.

Jesper

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ECOS] cyg_io_read
@ 2000-08-22 13:11 Eric Fradette
  2000-08-23  5:57 ` Jesper Skov
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Fradette @ 2000-08-22 13:11 UTC (permalink / raw)
  To: Ecos-Discuss

Hi,

I am using the function cyg_io_read() with AEB-1, and am running into a
problem in that it appears that cyg_io_read() returns when it encounters 0x0
(the ASCII NUL character).  Is this correct?  If it is, how can I keep it
from doing this since that is part of that data that I need.  Or, is there
some cyg_io_getc type of function that will retun the character no matter
what it is.

Thanks,
Eric

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ECOS] cyg_io_read
@ 2000-07-24 10:22 amassa
  0 siblings, 0 replies; 10+ messages in thread
From: amassa @ 2000-07-24 10:22 UTC (permalink / raw)
  To: jlarmour; +Cc: ecos-discuss

I am trying to get input from the /dev/tty1 device.  I have attached the
code snippet I am using.  However, I am unable to get any input from the
serial port.  I am running on an MBX board.  I can send output to the port
using cyg_io_write for the /dev/tty1 device.  The device seems to get
initialized properly from the cyg_io_lookup call - there is no error
returned.  I never return from the call to cyg_io_read.

I have also tried this with GDB in the stubs disabled.

Can you give me some suggestions or reasons why this is not working?

CODE...

   UCHAR ucCommandBuffer[ MAX_COMMAND_LENGTH ];
   cyg_uint32 uiCommandLength;
   Cyg_ErrNo erError;
   CHAR cCliDeviceName[ ] = "/dev/tty1";
   cyg_io_handle_t  hCliDevice;

   erError = cyg_io_lookup( cCliDeviceName, &hCliDevice );

   uiCommandLength = 10;
   erError = cyg_io_read( hCliDevice, ucCommandBuffer, uiCommandLength );


Thanks for any help you can give,
Anthony

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-04-20 10:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-20 12:01 [ECOS] cyg_io_read grahamlab
  -- strict thread matches above, loose matches on Subject: below --
2005-03-15 13:34 baljeet singh
2005-03-15 14:21 ` Gary Thomas
2005-03-16  4:24 ` Marco SICHERI [CTS]
2000-08-22 13:11 Eric Fradette
2000-08-23  5:57 ` Jesper Skov
     [not found]   ` <NEBBLBCPCLNPKNANBKIKOEPLCBAA.emf8@po.cwru.edu>
2000-08-23  6:18     ` Jesper Skov
2000-08-23  6:23       ` Eric Fradette
2000-08-23  8:06         ` Jesper Skov
2000-07-24 10:22 amassa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).