|
|
View previous topic :: View next topic |
Author |
Message |
Danny Guest
|
CASE STATEMENT ERROR |
Posted: Tue Apr 29, 2003 9:00 am |
|
|
I'm using the rs232 to get a message from another pic. this part of my circuit functions correctly. i use the getc() function in ccs, so the pic waits for a byte to be recieved. However as i need to filter messages, i.e certain messages do different actions, my program program hangs when the case statement finishes. i have a bi-led lighting, and this flashes green red every time a message is recieved, but when the case statement is excuted, the led goes off and the pic appears to hang.
Can anyone help????????? also if there are any other ways of filtering messages??
___________________________
This message was ported from CCS's old forum
Original Post ID: 14053 |
|
|
Sherpa Doug Guest
|
Re: CASE STATEMENT ERROR |
Posted: Tue Apr 29, 2003 9:51 am |
|
|
:=I'm using the rs232 to get a message from another pic. this part of my circuit functions correctly. i use the getc() function in ccs, so the pic waits for a byte to be recieved. However as i need to filter messages, i.e certain messages do different actions, my program program hangs when the case statement finishes. i have a bi-led lighting, and this flashes green red every time a message is recieved, but when the case statement is excuted, the led goes off and the pic appears to hang.
:=
:=Can anyone help????????? also if there are any other ways of filtering messages??
First - Please give the BBS a minute and reload to see if your message is there.....
Second - Here is how I read and parse simple commands:
switch (toupper(getch())) {
case 'F':
key = getch();
while (isdigit(key)) {
sum = (sum * 10) + (key - '0');
key = getch();
}
If ((sum > MinFreq) && (sum < MaxFreq)) {
dPhase = sum;
}
else {
putc( 21 ); //Freq is bad, send
}
break;
case 'D':
key = getch();
while (isdigit(key)) {
sum = (sum * 10) + (key - '0');
key = getch();
}
dly = (int)(sum/1000);
break;
case 'P':
key = getch();
if (key != '0'){
Pinger = true;
puts("P = true");
}
else{
Pinger = false;
puts("P = false");
}
break;
case '?':
Verbose = true;
break;
case 13: //ignore spurious <CR> or <LF>, don't send <NAK>
case 10:
break;
default: //Command not recognized
puts("Command not recognized\n\r");
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 14054 |
|
|
Dave Yeatman Guest
|
Re: CASE STATEMENT ERROR |
Posted: Tue Apr 29, 2003 2:37 pm |
|
|
<font face="Courier New" size=-1>It would be helpful if you showed the receive and filter routines so we can help determine what is wrong. Is the filter tied to the receive routine directly somehow?? How is the receive routine structured?? In my case I use the first letter to trim the candidates and then work my way through the message at key points.
Dave
:=I'm using the rs232 to get a message from another pic. this part of my circuit functions correctly. i use the getc() function in ccs, so the pic waits for a byte to be recieved. However as i need to filter messages, i.e certain messages do different actions, my program program hangs when the case statement finishes. i have a bi-led lighting, and this flashes green red every time a message is recieved, but when the case statement is excuted, the led goes off and the pic appears to hang.
:=
:=Can anyone help????????? also if there are any other ways of filtering messages??
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14063 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: CASE STATEMENT ERROR |
Posted: Thu May 01, 2003 3:17 pm |
|
|
:=I'm using the rs232 to get a message from another pic. this part of my circuit functions correctly. i use the getc() function in ccs, so the pic waits for a byte to be recieved. However as i need to filter messages, i.e certain messages do different actions, my program program hangs when the case statement finishes. i have a bi-led lighting, and this flashes green red every time a message is recieved, but when the case statement is excuted, the led goes off and the pic appears to hang.
:=
:=Can anyone help????????? also if there are any other ways of filtering messages??
The method I use is to recieve an entire packet before processing it. I do this with an interupt that stores bytes to a buffer. Every time I recieve a byte I set a timers value. If that timer overflows the byte stream has stoped and I can begin processing the packet. The timer interupt sets a packet complete flag that I check for from 'main'. I do use case statements to process the packets though. One thing about case statements is that you really should be sure to include a default case.
___________________________
This message was ported from CCS's old forum
Original Post ID: 14130 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|