PicoC string compare

122 views
Skip to first unread message

Viktor Granbom

unread,
Jun 12, 2019, 4:02:17 AM6/12/19
to Loxone English
Hi, can anyone help me with some simple string comparison in PicoC?

I have a elextrolux pure i9 robot cleaner that can send it's status to loxone through a virtual text input. I need to compare these text strings and convert them to a number so i can turn off my motion sensors when the robot is running.

/Viktor

Andrew B

unread,
Jun 12, 2019, 8:27:29 PM6/12/19
to Loxone English

if (strcmp(mystring, "matchstring") == 0)
{
    // mystring has a value of "matchstring" if you get here... 
    //     strcmp returns 0 on a match, and -1/+1 depending on ordering of not matching strings

Viktor Granbom

unread,
Jun 19, 2019, 2:05:30 AM6/19/19
to Loxone English
Thank you!

Finally got this simple script working:

#define BUFF_SIZE 256

char szBuffer[BUFF_SIZE];

while(1)
{
szBuffer = getinputtext(0);

if (strcmp(szBuffer, "Sleeping") == 0)
{
setoutput(0, 1);
}
if (strcmp(szBuffer, "PausedCleaning") == 0)
{
setoutput(0, 2);
}
if (strcmp(szBuffer, "Cleaning") == 0)
{
setoutput(0, 3);
}
if (strcmp(szBuffer, "Return") == 0)
{
setoutput(0, 4);
}
if (strcmp(szBuffer, "Charging") == 0)
{
setoutput(0, 5);
}

sleep(1000);
}

Now it doesn't set of the alarm all the time:) 

Tico

unread,
Jun 19, 2019, 7:48:41 AM6/19/19
to Loxone English
This is probably a bit late for you, however in the most recent Config version (10.2.3.26), the capability to do string comparisons is now available. It will use slightly less Miniserver resources using a Status Block versus a Program Block.


String Comparisons.png

Viktor Granbom

unread,
Jun 28, 2019, 3:15:28 AM6/28/19
to Loxone English
Thank you, change my program to this now. Much easier and more fail-safe than me programming in picoC!
Reply all
Reply to author
Forward
0 new messages