public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] Serial Application
@ 2001-04-26 18:23 Ho Shui Choy Stanley PS03B NCS
  2001-04-27  3:12 ` Robert Cragie
  2001-04-27  3:30 ` Carlos Camargo
  0 siblings, 2 replies; 5+ messages in thread
From: Ho Shui Choy Stanley PS03B NCS @ 2001-04-26 18:23 UTC (permalink / raw)
  To: 'Jonathan Larmour'; +Cc: Ecos-Discuss (E-mail)

Ok

Below is the code, those statements mark with an "*" did execute
When I call printf or cyg_io_write to /dev/haldiag, I see the messages on
COM1 on the hyperterminal, which is connected to serial port 0 on my target.
COM2 is connected to second serial port on my target.

I have tried to look up both ser0 and ser1, both returned with no error.
When I do a cyg_io_write to them nothing get displayed on the hyperterminal.

*   err = cyg_io_lookup( "/dev/haldiag", &handle );

   if (ENOERR == err) {
*        printf("Found /dev/haldiag. Writing string....\n");
*        err = cyg_io_write( handle, test_string, &len );
    }
        
    if (ENOERR == err) {
*        printf("I think I wrote the string. Did you see it?\n");
    }

*    err = cyg_io_lookup( "/dev/ser1", &serial );

    if (ENOERR == err) {
*        printf("Found /dev/ser1. Writing string....\n");

	   >>Not this statement, nothing is receive through serial_1
         err = cyg_io_write( serial, test_string, &len );
    }

    if (ENOERR == err) {
*        printf("I think I wrote the string to serial 1. Did you see
it?\n");
    }

Thanks
Stanley

-----Original Message-----
From: Jonathan Larmour [ mailto:jlarmour@redhat.com ]
Sent: Friday, April 27, 2001 02:14
To: Ho Shui Choy Stanley PS03B NCS
Cc: Ecos-Discuss (E-mail)
Subject: Re: [ECOS] Serial Application


Ho Shui Choy Stanley PS03B NCS wrote:
> 
> The flow control was disabled.
> 
> I receive the printf statements on /dev/haldiag. When I do a lookup on
ser0
> or ser1 there is no error. Even if /dev/haldiag is tied to ser0 or ser1, I
> should have got the message on that port but nothing is coming out.

I'm still not clear on exactly what you do see. Does /dev/haldiag itself
work? Does the initial cyg_io_write work?

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine

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

* RE: [ECOS] Serial Application
  2001-04-26 18:23 [ECOS] Serial Application Ho Shui Choy Stanley PS03B NCS
@ 2001-04-27  3:12 ` Robert Cragie
  2001-04-27  3:30 ` Carlos Camargo
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Cragie @ 2001-04-27  3:12 UTC (permalink / raw)
  To: Ho Shui Choy Stanley  PS03B  NCS, 'Jonathan Larmour'
  Cc: Ecos-Discuss (E-mail)

See inline comments.

> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [ mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Ho Shui Choy
> Stanley PS03B NCS
> Sent: 27 April 2001 02:21
> To: 'Jonathan Larmour'
> Cc: Ecos-Discuss (E-mail)
> Subject: RE: [ECOS] Serial Application
>
>
> Ok
>
> Below is the code, those statements mark with an "*" did execute
> When I call printf or cyg_io_write to /dev/haldiag, I see the messages on
> COM1 on the hyperterminal, which is connected to serial port 0 on
> my target.
> COM2 is connected to second serial port on my target.
>
> I have tried to look up both ser0 and ser1, both returned with no error.
> When I do a cyg_io_write to them nothing get displayed on the
> hyperterminal.
>
> *   err = cyg_io_lookup( "/dev/haldiag", &handle );
>
>    if (ENOERR == err) {
> *        printf("Found /dev/haldiag. Writing string....\n");
> *        err = cyg_io_write( handle, test_string, &len );

I can't see you actually setting 'len' before the call to cyg_io_write()
here (see below)...

>     }
>
>     if (ENOERR == err) {
> *        printf("I think I wrote the string. Did you see it?\n");
>     }
>
> *    err = cyg_io_lookup( "/dev/ser1", &serial );
>
>     if (ENOERR == err) {
> *        printf("Found /dev/ser1. Writing string....\n");
>
> 	   >>Not this statement, nothing is receive through serial_1
>          err = cyg_io_write( serial, test_string, &len );

I can't see you actually setting 'len' before the call to cyg_io_write()
here.

You set 'len' to be the desired length to write. It returns with the actual
length written in 'len':

           len = strlen(test_string);
           err = cyg_io_write( serial, test_string, &len );

Looking at the source, if len is passed as 0, cyg_io_write() will simply
return ENOERR without doing anything. The comment says that passing len=0
simply verifies the method exists.

This doesn't explain why cyg_io_write() to /dev/haldiag works (I assume it
does), unless it is handled differently in the call.

Robert Cragie
Design Engineer
Jennic Ltd.
Furnival Street
Sheffield
S1 4QT
United Kingdom
Tel: +44 (0) 114 281 4512
Fax: +44 (0) 114 281 2951
mailto:rcc@jennic.com
http://www.jennic.com



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

* RE: [ECOS] Serial Application
  2001-04-26 18:23 [ECOS] Serial Application Ho Shui Choy Stanley PS03B NCS
  2001-04-27  3:12 ` Robert Cragie
@ 2001-04-27  3:30 ` Carlos Camargo
  2001-04-27  4:13   ` Robert Cragie
  1 sibling, 1 reply; 5+ messages in thread
From: Carlos Camargo @ 2001-04-27  3:30 UTC (permalink / raw)
  To: ecos-discuss

Hi all..

My problem is:

I use mbox to transfer data between two threads, now i
able to send only int data.

I want send complex data with mbox, i define a struct
(  more complex that the example in my previous mail),
but i can't put or get messages of struct type.

Thanks

Carlos camargo

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

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

* RE: [ECOS] Serial Application
  2001-04-27  3:30 ` Carlos Camargo
@ 2001-04-27  4:13   ` Robert Cragie
  2001-04-27  4:36     ` [ECOS] Sorry Carlos Camargo
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Cragie @ 2001-04-27  4:13 UTC (permalink / raw)
  To: Carlos Camargo, ecos-discuss

You could use the cyg_mbox_...() functions in conjunction with an array of
your structures initially organised in a linked list, maintaining a variable
which points to the head of this linked list (call this the 'free pool').

To send from Thread A to Thread B, Thread A would remove a structure from
(the head of) the free pool, fill its contents, then send to Thread B using
cyg_mbox_put(), with the pointer to this structure as the 'item' in
cyg_mbox_put().

Thread B would use cyg_mbox_get() (or cyg_mbox_timed_get()) to retrieve the
pointer value, which it would then dereference to get to the contents. Once
Thread B has finished with it, it can either reclaim it directly to the free
pool, in which case you would need a mutex to ensure only one thread can
access the free pool at any one time, or you could set up a mailbox to
return the pointer back to Thread A, which would then reclaim it; in this
case you wouldn't need mutex protection if only Thread A was ever going to
access the free pool.

Note the number of structures in your free pool should match the number of
entries in the mailbox, which is specified by
CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE, and defaults to 10, I believe.

Hope this helps

Robert Cragie
Design Engineer
Jennic Ltd.
Furnival Street
Sheffield
S1 4QT
United Kingdom
Tel: +44 (0) 114 281 4512
Fax: +44 (0) 114 281 2951
mailto:rcc@jennic.com
http://www.jennic.com

> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [ mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Carlos
> Camargo
> Sent: 27 April 2001 11:30
> To: ecos-discuss@sources.redhat.com
> Subject: RE: [ECOS] Serial Application
>
>
> Hi all..
>
> My problem is:
>
> I use mbox to transfer data between two threads, now i
> able to send only int data.
>
> I want send complex data with mbox, i define a struct
> (  more complex that the example in my previous mail),
> but i can't put or get messages of struct type.
>
> Thanks
>
> Carlos camargo
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/

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

* [ECOS] Sorry
  2001-04-27  4:13   ` Robert Cragie
@ 2001-04-27  4:36     ` Carlos Camargo
  0 siblings, 0 replies; 5+ messages in thread
From: Carlos Camargo @ 2001-04-27  4:36 UTC (permalink / raw)
  To: Robert Cragie, ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Sorry for my simple question, in the future i don´t
make this kind of answer.

Thanks for all..


Carlos Camargo

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

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

end of thread, other threads:[~2001-04-27  4:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-26 18:23 [ECOS] Serial Application Ho Shui Choy Stanley PS03B NCS
2001-04-27  3:12 ` Robert Cragie
2001-04-27  3:30 ` Carlos Camargo
2001-04-27  4:13   ` Robert Cragie
2001-04-27  4:36     ` [ECOS] Sorry Carlos Camargo

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).