View previous topic :: View next topic |
Author |
Message |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
Another serial question |
Posted: Tue Feb 08, 2011 10:18 am |
|
|
HI Guys I have a issue reading in more than two serial bytes.
Code: | BOOLEAN waitForResponse( int32 timeout, byte buffer[], int8 bufferLength )
{
int8 byteCnt = 0;
int32 time = 0;
while(kbhit(CAMERA)&&(++time<timeout))
{
buffer[byteCnt] = fgetc(CAMERA);
if( byteCnt == bufferLength )
{
return (1);
}
byteCnt++;
}
return (0);
} |
I'm reading in a total of 6 bytes of which the first two are always correct but the last four are garbage.
Any suggestions ??
Thx _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
![](templates/subSilver/images/spacer.gif) |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Feb 08, 2011 10:25 am |
|
|
Hi,
Yes, two suggestions:
1. Add the ERRORS directive to your #Use RS232 statement
2. Read the forum everyday as this and other similar problems are covered repeatedly here....
John |
|
![](templates/subSilver/images/spacer.gif) |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
int_rda |
Posted: Tue Feb 08, 2011 1:49 pm |
|
|
Thx I will try and set up a int driven routine.
Regards _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
![](templates/subSilver/images/spacer.gif) |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
|
Posted: Wed Feb 09, 2011 1:57 pm |
|
|
Ok I solved the problem by adding an isr for my serial bit sream that the pic receives. _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
![](templates/subSilver/images/spacer.gif) |
|