View previous topic :: View next topic |
Author |
Message |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
undefined identifier STREAM_UART |
Posted: Sat Aug 08, 2009 6:40 pm |
|
|
Hi can any one please tell me how to use the following code? I get an error when I compile it, undefined identifier STREAM_UART.
Code: |
void pc_recv_check(void)
{
char string1[80], string2[5];
if (kbhit(STREAM_UART))
{
strcpy(string2, "fred"); //This will automatically add '\0' to the end of your string and is neater
fgets(string1, STREAM_UART);
if(strcmp(string1, string2) == 0) // strcmp returns 0 if they are equal!
{
fprintf(STREAM_UART, "Password_OK\r\n "); //Print ok if they match
}
else
{
fprintf(STREAM_UART, "Password_BAD\r\n "); // Print BAD if they dont match
}
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Aug 08, 2009 7:38 pm |
|
|
Make sure you have a #use rs232() statement that specifies that identifier
as the stream. |
|
|
deltatech
Joined: 22 Apr 2006 Posts: 87
|
|
Posted: Sun Aug 09, 2009 6:07 am |
|
|
Hi PCM PROGRAMMER Thanks for your reply . Can you please give an example what you mean, or how to do it. Many thanks in advance. |
|
|
deltatech
Joined: 22 Apr 2006 Posts: 87
|
|
Posted: Sun Aug 09, 2009 7:36 am |
|
|
I have managed to compile now, but I do not get anything on the Hyperterminal. Can anyone please tell me what I am doing wrong ? Many thanks
Code: |
#include "L:\Program Files\PICC\Project\RF-RS232\streamuart.h"
#include <string.h> // This at the top of your file somewhere !
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, PARITY=E, BITS=7,STREAM=STREAM_UART)
#include <string.h>
void pc_recv_check(void);
void main()
{
pc_recv_check();
}
void pc_recv_check(void)
{
char string1[80], string2[5];
if (kbhit(STREAM_UART))
{
strcpy(string2, "fred"); //This will automatically add '\0' to the end of your string and is neater
fgets(string1, STREAM_UART);
if(strcmp(string1, string2) == 0) // strcmp returns 0 if they are equal!
{
fprintf(STREAM_UART, "Password_OK\r\n "); //Print ok if they match
}
else
{
fprintf(STREAM_UART, "Password_BAD\r\n "); // Print BAD if they dont match
}
}
}
|
|
|
|
Ttelmah Guest
|
|
Posted: Sun Aug 09, 2009 12:22 pm |
|
|
You won't....
When the chip wakes up, will a character have been received?.
Without a received character, what will 'kbhit' return?.
Once this has been tested, your code then goes on, and runs 'off the end'. Will anything then be received?.
You need to _loop_ and wait for data.
Best Wishes |
|
|
Guest
|
|
Posted: Sun Aug 09, 2009 9:35 pm |
|
|
I notice that BOTH of your possible transmit messages
add an extra space in a weird place - AFTER the \r\n.
Do you mean to do that ? |
|
|
|