It shouldn’t make a difference. Just make sure your send and receive buffers are large enough (especially the receive side if you are not reading the serial port very fast).
I would advise against ever flushing a serial port write buffer…
Nathan
-----Original
Message-----
From: r...@yahoogroups.com
[mailto:r...@yahoogroups.com] On
Behalf Of stujo
Sent: Monday, 1
August 2005 2:32 PM
To: r...@yahoogroups.com
Subject: [rabbit-semi] Re: serial
headache again
Thanks a million Nathan !!!
I changed the code as suggested and it works
great. Now the answer
only breeds more questions. What needs to be done
for a string that
grows or shrinks?
--- In r...@yahoogroups.com, "Nathan
Johnston" <nathanj@d...>
wrote:
> I think your problem is with flushing the
serial port every time you
> send something, i.e. you are flushing data
that is yet to exit the
> serial libraries circular buffer (on route to
the UART). Just flush
it
> once before you enter your while
loop.
>
> Also, serXopen accepts a long, but you are
passing it an int (type
> defaults to int when not defined). Pass
19200L instead.
>
> Nathan
> =============
> Sending Code:
> =============
> #class auto
> #define DINBUFSIZE 15
> #define DOUTBUFSIZE 15
> #define SERD_CTS_PORT PCDR
> #define SERD_CTS_BIT 3
> #define SERD_RTS_PORT PCDR
> #define SERD_RTS_SHADOW
PCDRShadow
> #define SERD_RTS_BIT 2
> const char s[] =
"Hello";
> void main(){
>
serDopen(19200L);
>
serDflowcontrolOn();
> loopinit();
>
serDwrFlush();
> while(1){
>
costate{
>
wfd cof_serDputs(s);
>
}
>
printf("%s\n",s);
> }
> serDclose();
> }
>
> ===============
> Receiving Code:
> ===============
>
> #class auto
> #define DINBUFSIZE 63
> #define DOUTBUFSIZE 63
> #define timeout 20UL
> #define SERD_CTS_PORT PCDR
> #define SERD_CTS_BIT 3
> #define SERD_RTS_PORT PCDR
> #define SERD_RTS_SHADOW
PCDRShadow
> #define SERD_RTS_BIT 2
>
> main() {
> int getOk;
> char s[16];
>
serDopen(19200L);
>
serDflowcontrolOn();
> loopinit();
> while (1) {
>
loophead();
> costate
{
>
wfd getOk = cof_serDgets (s, 5, timeout);
>
if (getOk)
>
printf("%s\n",s);
>
else {
>
printf(" - FAILED - \n");
>
}
>
}
> }
> serDclose();
> }_______________________
I think your problem is with flushing the serial port every time you send something, i.e. you are flushing data that is yet to exit the serial libraries circular buffer (on route to the UART). Just flush it once before you enter your while loop.
Also, serXopen accepts a long, but you are passing it an int (type defaults to int when not defined). Pass 19200L instead.
Nathan
-----Original
Message-----
From: r...@yahoogroups.com
[mailto:r...@yahoogroups.com] On
Behalf Of stujo
Sent: Monday, 1
August 2005 1:24 PM
To: r...@yahoogroups.com
Subject: [rabbit-semi] serial
headache again
Simple task but I make it so
difficult. I have 2 RCM2200 modules
connected serially. Using port D I have TXD going
to RXD, RTS going to
CTS, GND going to GND. (pins PC0 to PC1, PC2 to
PC3, etc) All
connections are sound. On Rabbit A I have a
continuous loop sending
"HELLO" to Rabbit B. Rabbit B runs
through a constant loop reading
port D and printing what it receives to the
screen. No matter what I
try it prints the first 2 character (H & E) in
a mixed up pattern. It
seems to me I have a timing problem but what do I
know. Please help,
before I check myself into the mental ward
;^)
=============
Sending Code:
=============
#class auto
#define DINBUFSIZE 15
#define DOUTBUFSIZE 15
#define SERD_CTS_PORT PCDR
#define SERD_CTS_BIT 3
#define SERD_RTS_PORT PCDR
#define SERD_RTS_SHADOW PCDRShadow
#define SERD_RTS_BIT 2
const char s[] = "Hello";
void main(){
serDopen(19200);
serDflowcontrolOn();
loopinit();
while(1){
costate{
serDwrFlush();
wfd cof_serDputs(s);
}
printf("%s\n",s);
}
serDclose();
}
===============
Receiving Code:
===============
#class auto
#define DINBUFSIZE 63
#define DOUTBUFSIZE 63
#define timeout 20UL
#define SERD_CTS_PORT PCDR
#define SERD_CTS_BIT 3
#define SERD_RTS_PORT PCDR
#define SERD_RTS_SHADOW PCDRShadow
#define SERD_RTS_BIT 2
main() {
int getOk;
char s[16];
serDopen(19200);
serDflowcontrolOn();
loopinit();
while (1) {
loophead();
costate
{
wfd getOk = cof_serDgets (s, 15, timeout);
if (getOk)
printf("%s\n",s);
else {
printf(" - FAILED - \n");
}
}
}
serDclose();
}
======
OUTPUT
======
eHHHHHHHHHHHHeH
HHHHHHHHHHHHeHH
HHHHHHHHeHHHHHH
HHHHeHHHHHHHHHe
HHHHHHHHHHHHeHH
HHHHHHHHHHHeHHH
HHHHHHHHHeHHHHH
HHHHHHHeHHHHHHH
HHHHHeHHHHHHHHH
HeHHHHHHHHHHeHH
HHHHHHHHHeHHHHH
HHHHHHHeHHHHHHH
HHHHHHHeHHHHHHH
Thanks in advance,
stujo