¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

SIMPL+ help...REMOVE


etienneterblanche
 

Hi,

I need to extract the a section of the following string to get the current status of an indoor Daikin unit.

Tx$ to CoolMaster = stat3 101\x0D\x0A

Rx$ from CoolMaster = \x0D\x0A101 OFF 32C 24C Low Dry OK 1\x0D\x0AOK\x0D\x0A\x0D\x0A

I currently use the following, but for some reason it doesn't update any of the serial outputs.

Some notes:
1) UID$ = 3 digit serial I'm passing to the SIMPL+ module

2) The first 3 characters of the REMOVE string must match UID$. In this example it is "101".

3) The rest of the sections within the REMOVE string always starts at the same char position within the string.

----------------------------------------------------------------------
CHANGE Rx$
{
WHILE (FIND("\x0D",Rx$,3))
{
tempStr = REMOVE("\x0D",Rx$,3);
VAL1 = ATOI(UID$);
VAL2 = ATOI(LEFT(tempStr, 5));

IF (VAL2 = VAL1)
{
Status$ = mid(tempStr, 7, 3);
Set_Temp$ = mid(tempStr, 11, 3);
Room_Temp$ = mid(tempStr, 15, 3);
Fan_Speed$ = mid(tempStr, 19, 4);
Operation$ = mid(tempStr, 24, 4);

tempStr = "";
}

ELSE
{
tempStr = "";
VAL1 = 0;
VAL2 = 0;
}

}
}
----------------------------------------------------------------------

Thank you!!
Et


Chip
 

You're removing up to the &#92;x0D, which means that the >next< string to be removed is going to have &#92;x0A as the first byte, so your first three characters are never going to match what you're looking for. Try doing your FIND/REMOVE against "&#92;x0D&#92;x0A".

Instead of looking for the third instance, you might be better off doing your removes against the first, and just have your parsing code check to see if the REMOVED string is long enough to possibly contain your data before parsing it. By searching for every third instance, I'd be worried about data getting out of alignment whack.

After checking the length of your removed string, you can simplify your UID check by doing something like

IF (LEFT(tempStr, 3) = UID$)
{
do stuff
}

- Chip

--- In Crestron@..., "etienneterblanche" <etienne@...> wrote:

Hi,

I need to extract the a section of the following string to get the current status of an indoor Daikin unit.

Tx$ to CoolMaster = stat3 101&#92;x0D&#92;x0A

Rx$ from CoolMaster = &#92;x0D&#92;x0A101 OFF 32C 24C Low Dry OK 1&#92;x0D&#92;x0AOK&#92;x0D&#92;x0A&#92;x0D&#92;x0A

I currently use the following, but for some reason it doesn't update any of the serial outputs.

Some notes:
1) UID$ = 3 digit serial I'm passing to the SIMPL+ module

2) The first 3 characters of the REMOVE string must match UID$. In this example it is "101".

3) The rest of the sections within the REMOVE string always starts at the same char position within the string.

----------------------------------------------------------------------
CHANGE Rx$
{
WHILE (FIND("&#92;x0D",Rx$,3))
{
tempStr = REMOVE("&#92;x0D",Rx$,3);
VAL1 = ATOI(UID$);
VAL2 = ATOI(LEFT(tempStr, 5));

IF (VAL2 = VAL1)
{
Status$ = mid(tempStr, 7, 3);
Set_Temp$ = mid(tempStr, 11, 3);
Room_Temp$ = mid(tempStr, 15, 3);
Fan_Speed$ = mid(tempStr, 19, 4);
Operation$ = mid(tempStr, 24, 4);

tempStr = "";
}

ELSE
{
tempStr = "";
VAL1 = 0;
VAL2 = 0;
}

}
}
----------------------------------------------------------------------

Thank you!!
Et


etienneterblanche
 

Thanks Chip! Worked Great!

--- In Crestron@..., "Chip" <cfm@...> wrote:


You're removing up to the &#92;x0D, which means that the >next< string to be removed is going to have &#92;x0A as the first byte, so your first three characters are never going to match what you're looking for. Try doing your FIND/REMOVE against "&#92;x0D&#92;x0A".

Instead of looking for the third instance, you might be better off doing your removes against the first, and just have your parsing code check to see if the REMOVED string is long enough to possibly contain your data before parsing it. By searching for every third instance, I'd be worried about data getting out of alignment whack.

After checking the length of your removed string, you can simplify your UID check by doing something like

IF (LEFT(tempStr, 3) = UID$)
{
do stuff
}

- Chip


--- In Crestron@..., "etienneterblanche" <etienne@> wrote:

Hi,

I need to extract the a section of the following string to get the current status of an indoor Daikin unit.

Tx$ to CoolMaster = stat3 101&#92;x0D&#92;x0A

Rx$ from CoolMaster = &#92;x0D&#92;x0A101 OFF 32C 24C Low Dry OK 1&#92;x0D&#92;x0AOK&#92;x0D&#92;x0A&#92;x0D&#92;x0A

I currently use the following, but for some reason it doesn't update any of the serial outputs.

Some notes:
1) UID$ = 3 digit serial I'm passing to the SIMPL+ module

2) The first 3 characters of the REMOVE string must match UID$. In this example it is "101".

3) The rest of the sections within the REMOVE string always starts at the same char position within the string.

----------------------------------------------------------------------
CHANGE Rx$
{
WHILE (FIND("&#92;x0D",Rx$,3))
{
tempStr = REMOVE("&#92;x0D",Rx$,3);
VAL1 = ATOI(UID$);
VAL2 = ATOI(LEFT(tempStr, 5));

IF (VAL2 = VAL1)
{
Status$ = mid(tempStr, 7, 3);
Set_Temp$ = mid(tempStr, 11, 3);
Room_Temp$ = mid(tempStr, 15, 3);
Fan_Speed$ = mid(tempStr, 19, 4);
Operation$ = mid(tempStr, 24, 4);

tempStr = "";
}

ELSE
{
tempStr = "";
VAL1 = 0;
VAL2 = 0;
}

}
}
----------------------------------------------------------------------

Thank you!!
Et


mjrtoo2000
 

As a side note, the method you're using has been discussed in great detail the last few weeks and I think the majority of people would consider the the method your using to be not ideal. The CHANGE statement without a gather causes multiple threads to be spawned wen new data is received, the REMOVE statement causes the entire buffer to be re-evaluated each time new data is received rather than when using a GATHER which suspends the loop, and re-evaluates the buffer on a character basis from where it was suspended, not from the beginning.

I think the conclusion here is that WHILE(1) / GATHER inside the FUNCTION_MAIN (or in a push statement to be able to start/stop the loop) is a superior way to handle this type of code. Oh, and you're not doing it in the code below, but avoid calling a function from within a WHILE(1) loop if you're receiving a lot of data, put the parsing routine inside the loop, it saves A LOT of overhead.

Might be splitting hairs if you're not receiving a lot of data on rx$, but good practice is good practice.

(hopefully that's not all wrong... ;) )

--- In Crestron@..., "etienneterblanche" <etienne@...> wrote:

Hi,

I need to extract the a section of the following string to get the current status of an indoor Daikin unit.

Tx$ to CoolMaster = stat3 101&#92;x0D&#92;x0A

Rx$ from CoolMaster = &#92;x0D&#92;x0A101 OFF 32C 24C Low Dry OK 1&#92;x0D&#92;x0AOK&#92;x0D&#92;x0A&#92;x0D&#92;x0A

I currently use the following, but for some reason it doesn't update any of the serial outputs.

Some notes:
1) UID$ = 3 digit serial I'm passing to the SIMPL+ module

2) The first 3 characters of the REMOVE string must match UID$. In this example it is "101".

3) The rest of the sections within the REMOVE string always starts at the same char position within the string.

----------------------------------------------------------------------
CHANGE Rx$
{
WHILE (FIND("&#92;x0D",Rx$,3))
{
tempStr = REMOVE("&#92;x0D",Rx$,3);
VAL1 = ATOI(UID$);
VAL2 = ATOI(LEFT(tempStr, 5));

IF (VAL2 = VAL1)
{
Status$ = mid(tempStr, 7, 3);
Set_Temp$ = mid(tempStr, 11, 3);
Room_Temp$ = mid(tempStr, 15, 3);
Fan_Speed$ = mid(tempStr, 19, 4);
Operation$ = mid(tempStr, 24, 4);

tempStr = "";
}

ELSE
{
tempStr = "";
VAL1 = 0;
VAL2 = 0;
}

}
}
----------------------------------------------------------------------

Thank you!!
Et


etienneterblanche
 

I would like to make sure I follow best practices and will give it a try!

Thanks!

--- In Crestron@..., "mjrtoo2000" <mjrtoo@...> wrote:

As a side note, the method you're using has been discussed in great detail the last few weeks and I think the majority of people would consider the the method your using to be not ideal. The CHANGE statement without a gather causes multiple threads to be spawned wen new data is received, the REMOVE statement causes the entire buffer to be re-evaluated each time new data is received rather than when using a GATHER which suspends the loop, and re-evaluates the buffer on a character basis from where it was suspended, not from the beginning.

I think the conclusion here is that WHILE(1) / GATHER inside the FUNCTION_MAIN (or in a push statement to be able to start/stop the loop) is a superior way to handle this type of code. Oh, and you're not doing it in the code below, but avoid calling a function from within a WHILE(1) loop if you're receiving a lot of data, put the parsing routine inside the loop, it saves A LOT of overhead.

Might be splitting hairs if you're not receiving a lot of data on rx$, but good practice is good practice.

(hopefully that's not all wrong... ;) )

--- In Crestron@..., "etienneterblanche" <etienne@> wrote:

Hi,

I need to extract the a section of the following string to get the current status of an indoor Daikin unit.

Tx$ to CoolMaster = stat3 101&#92;x0D&#92;x0A

Rx$ from CoolMaster = &#92;x0D&#92;x0A101 OFF 32C 24C Low Dry OK 1&#92;x0D&#92;x0AOK&#92;x0D&#92;x0A&#92;x0D&#92;x0A

I currently use the following, but for some reason it doesn't update any of the serial outputs.

Some notes:
1) UID$ = 3 digit serial I'm passing to the SIMPL+ module

2) The first 3 characters of the REMOVE string must match UID$. In this example it is "101".

3) The rest of the sections within the REMOVE string always starts at the same char position within the string.

----------------------------------------------------------------------
CHANGE Rx$
{
WHILE (FIND("&#92;x0D",Rx$,3))
{
tempStr = REMOVE("&#92;x0D",Rx$,3);
VAL1 = ATOI(UID$);
VAL2 = ATOI(LEFT(tempStr, 5));

IF (VAL2 = VAL1)
{
Status$ = mid(tempStr, 7, 3);
Set_Temp$ = mid(tempStr, 11, 3);
Room_Temp$ = mid(tempStr, 15, 3);
Fan_Speed$ = mid(tempStr, 19, 4);
Operation$ = mid(tempStr, 24, 4);

tempStr = "";
}

ELSE
{
tempStr = "";
VAL1 = 0;
VAL2 = 0;
}

}
}
----------------------------------------------------------------------

Thank you!!
Et