A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
string space on pics in basic - Lez - Aug 21 10:34:33 2006
Ok imagine this set of non standard basic statements..........
dim a$ as char(50)
for x=1 to 50
mid$(a$,x,1)=serin(port something)
next x
I end up with at least 50 chars from the serial port in a$
Now that I have them, I can parse them.
Imagine I am looking for keywords in that string.....
(say 'feed the' 'dog' 'cat' 'bones' 'meat' 'water' 'milk')
So I parse for valid instructions, otherwise I would forget and starve them...
So an incoming data stream of
''ghdfkghkdFEED THElkjgdjfCATjdflgjMILKjsdfjfjsdljfl"
would mean to milk the cat, sorry give milk to the cat...
But...........
''ghdfkghkdFEED THElkjgdjfMILKjdflgjCATjsdfjfjsdljfl"
would be the same, 'feed the milk cat' while out of context is valid idea.
'Feed the' is just a qualifier and once I have that I can look at the
rest of the burst of data I'm getting........
I have used
SERIN portb.7,t1200,1000,comserr3,["FEED THE"]
and it works a treat but........
I cant follow it with
SERIN portb.7,t1200,1000,comserr3,["CAT"]
because it may be time to feed the dog....
If I time out waiting for the cat, the dog may have run past, IYSWIM..........
So I need to store it, and then parse it ''offline''
I bet lots of newbies ask ones like this.............
Pic control was so much easier when I could just wire a switch to a pin!
--
Lez
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
RE: string space on pics in basic - Alan Marconett - Aug 21 11:36:35 2006
Hi Lez,
I'm not sure where you are going with this, but a typical way to handle this
is to use a "get token" routine to give you a token (word, like CAT) at a
time. Parse a line of input this way, and record the key words seen (check
each token seen against a list of key words).
Depending on your circumstance, you could DEFINE a simple syntax, rather
then just allowing ANY sentence structure (unless that IS your goal). With
a simple syntax, you can just look for the occurrence of verb, subject, and
object; and then know the operation wanted (FEED CAT MILK).
Does this help? You might get more answers on a robotics or C language
list!
Alan KM6VV
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> Of Lez
> Sent: Monday, August 21, 2006 7:34 AM
> To: p...@yahoogroups.com
> Subject: [piclist] string space on pics in basic
>
> Ok imagine this set of non standard basic statements..........
> dim a$ as char(50)
>
> for x=1 to 50
>
> mid$(a$,x,1)=serin(port something)
>
> next x
>
> I end up with at least 50 chars from the serial port in a$
> Now that I have them, I can parse them.
>
> Imagine I am looking for keywords in that string.....
>
> (say 'feed the' 'dog' 'cat' 'bones' 'meat' 'water' 'milk')
> So I parse for valid instructions, otherwise I would forget and starve
> them...
>
> So an incoming data stream of
>
> ''ghdfkghkdFEED THElkjgdjfCATjdflgjMILKjsdfjfjsdljfl"
>
> would mean to milk the cat, sorry give milk to the cat...
>
> But...........
>
> ''ghdfkghkdFEED THElkjgdjfMILKjdflgjCATjsdfjfjsdljfl"
>
> would be the same, 'feed the milk cat' while out of context is valid idea.
>
> 'Feed the' is just a qualifier and once I have that I can look at the
> rest of the burst of data I'm getting........
>
> I have used
>
> SERIN portb.7,t1200,1000,comserr3,["FEED THE"]
>
> and it works a treat but........
>
> I cant follow it with
>
> SERIN portb.7,t1200,1000,comserr3,["CAT"]
>
> because it may be time to feed the dog....
>
> If I time out waiting for the cat, the dog may have run past,
> IYSWIM..........
>
> So I need to store it, and then parse it ''offline''
>
> I bet lots of newbies ask ones like this.............
>
> Pic control was so much easier when I could just wire a switch to a pin!
>
> --
>
> Lez
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: string space on pics in basic - Lez - Aug 21 15:36:28 2006
. With
> a simple syntax, you can just look for the occurrence of verb, subject, and
> object; and then know the operation wanted (FEED CAT MILK).
>
> Does this help? You might get more answers on a robotics or C language
> list!
>
> Alan KM6VV
Thanks for the reply, I think I'm moving in the right direction, its a
simple remote control unit really, but I want to be able to use it
with a phone
Its for an alarm, I posted a while ago about it, found lots of old
designs on web, decided to have a go at building a new one with parts
that are still on the shelf.
Biggest problem I have is the more modern phones have dropped text
supprt and output all their messages in PDU mode, its 7 bit, in
octets, and nibble swapped, or something like that!
Only saving grace is that a message containg a keyword will always
look the same, provided its not off set by anything like an extra
space between words....
Ie 1234567 may be Feed cat, but 7434567 may be feed cat, so I can skip
the beginning to get around the capital letter, but feed cat. may be
134692 just because the full stop was added........
Only solution is to use long words as commands so any
punctuation/capitalisation leaves the middle niblets intact.
Best way would be to decode the whole thing, but when a language
limitation is 96 bytes to a byte array and a message could be double
that length (padding, system info, time date stamp) I'm at a loss!
Its a bigger project than I should be attempting with what I know and
really should shelve it for a year, but I want to stretch
myself.............
> > -----Original Message-----
> > From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> > Of Lez
> > Sent: Monday, August 21, 2006 7:34 AM
> > To: p...@yahoogroups.com
> > Subject: [piclist] string space on pics in basic
> >
> > Ok imagine this set of non standard basic statements..........
> >
> >
> > dim a$ as char(50)
> >
> > for x=1 to 50
> >
> > mid$(a$,x,1)=serin(port something)
> >
> > next x
> >
> > I end up with at least 50 chars from the serial port in a$
> >
> >
> > Now that I have them, I can parse them.
> >
> > Imagine I am looking for keywords in that string.....
> >
> > (say 'feed the' 'dog' 'cat' 'bones' 'meat' 'water' 'milk')
> >
> >
> > So I parse for valid instructions, otherwise I would forget and starve
> > them...
> >
> > So an incoming data stream of
> >
> > ''ghdfkghkdFEED THElkjgdjfCATjdflgjMILKjsdfjfjsdljfl"
> >
> > would mean to milk the cat, sorry give milk to the cat...
> >
> > But...........
> >
> > ''ghdfkghkdFEED THElkjgdjfMILKjdflgjCATjsdfjfjsdljfl"
> >
> > would be the same, 'feed the milk cat' while out of context is valid idea.
> >
> >
> >
> > 'Feed the' is just a qualifier and once I have that I can look at the
> > rest of the burst of data I'm getting........
> >
> > I have used
> >
> > SERIN portb.7,t1200,1000,comserr3,["FEED THE"]
> >
> > and it works a treat but........
> >
> > I cant follow it with
> >
> > SERIN portb.7,t1200,1000,comserr3,["CAT"]
> >
> > because it may be time to feed the dog....
> >
> > If I time out waiting for the cat, the dog may have run past,
> > IYSWIM..........
> >
> > So I need to store it, and then parse it ''offline''
> >
> >
> >
> >
> >
> > I bet lots of newbies ask ones like this.............
> >
> > Pic control was so much easier when I could just wire a switch to a pin!
> >
> > --
> >
> > Lez
>
--
Lez
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )