UART READ TEXT

Here you can ask for specific code examples and discuss about it with other forum members.
Post Reply
Author
Message
rjmendoza1987
Posts: 30
Joined: 27 Nov 2011 09:12

UART READ TEXT

#1 Post by rjmendoza1987 » 28 Apr 2012 10:14

Hi,

I can't really understand how to manage the data being received by the uart,
i want to read the data on text using select case procedure though i have several commands for it. im working for mikrobasic using PIC16F887

dim uart_rd as byte
if uart1_data_ready =1 then
uart_rd = uart1_read
select case uart
case LampOn -->first text i send from the host pc
portd.4 = 1
portc.5 = 1
case LampOff
portd.4 = 0
portd.5 = 0
case else
end select
delay_ms(100)
end if

I want to read the uart_rd as text as i send from host pc to mcu.
It comfiled but didn't work. I'm thinking what is the right declaration on how the mcu will read the text it received. But i have no problem on sending text to host pc since i'm using visual basic with select case procedure also which is working perfectly. But when i send the text to mcu, it can't read the same. My problem is that how to handle the text so that i cant On and OFF the port on mcu upon receiving command from the host. Hope anyone can understand.
To all masters please help us doing this, it would be helpful for me too much.

Thank you very much guys..i will wait for anyone can give me the right idea how to handle this

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: UART READ TEXT

#2 Post by janko.kaljevic » 30 Apr 2012 16:54

Hello,

Please notice that select expression requires one of the elementary data types.
You can not do it with strings.

First you will need to store entire message to a buffer. And then you can compare it with any desired message.
For this purpose you can use strcmp function from string library.

Best regards.

Post Reply

Return to “Code Requests”