c style string comparison

im working on a pendant that communicates between Grbl and the pc. its interupt driven so im not using the hardware serial libraries and im having trouble comparing some strings that contain numbers.
i usually use String objects so im sure its a simple issue due to lack of c knowledge.
the problem is the commented out "if " lines. if i compare to just the "$" it works fine but when i try the numbers if fails.
$1=200.0
$2=200.000
...
$130=200.000 (z max travel, mm)
$131=200.000 (z max travel, mm) im trying to find these 3 lines out of a list of similar.
$132=200.000 (z max travel, mm)

ISR(USART3_RX_vect)//RECIEVE from grbl
{
   char buffer[10];
   char inchar = GRBL_Read();
   Pc_Write(inchar);
   if(inchar==0x3C)storepos=true;//"<"
   if (storepos)
   {
       GrblPositionBuffer[GrblPositionBufferPos]=inchar;
       GrblPositionBufferPos++;
       if(inchar==0x3E)//">"
       {
           storepos=false;
           ParsePosString(GrblPositionBuffer);
           GrblPositionBufferPos=0;
       }

   }
   if(RecieveMachineSettings)// set true in setup before sending "$"
   {

       GrblSettingsBuffer[GrblSettingBufferPos]=inchar;
       GrblSettingBufferPos++;
       if(inchar= '\n')//"newline char"
       {
           //Example String >>>  $132=200.000 (z max travel, mm)
           //if (strncmp(GrblSettingsBuffer, "$132", 4) == 0) Pc_Print("it matches!");
           //if(GrblSettingsBuffer[2]='3' && GrblSettingsBuffer[3]='2')Pc_Print("it matches!");

           memset(GrblSettingsBuffer, 0, sizeof(GrblSettingsBuffer));  // clear buffer
           GrblSettingBufferPos=0;
       }
   }
   if(GrblPositionBufferPos >=127)
   {
       memset(GrblPositionBuffer, 0, sizeof(GrblPositionBuffer));
       GrblPositionBufferPos=0;

   }

}

i have tried several methods with no success. any help would be appreciated.

Please read the second and third posts by Nick Gammon at the top of this Forum on the proper way to post here, especially the use of code tags for source code. Also, how can we possibly help with only a snippet of code. That's like standing one inch away from the Empire State building and asking me how it looks.

the full code is 800 lines. the only other code that would apply would be

unsigned char GRBL_Read (void)
{
    while(!(UCSR3A) & (1<<RXC3));                   // wait while data is being received
    return UDR3;                                   // return 8-bit data
}

i assumed the ISR would tell you im reading from UDR.sorry

Don't post snippets. We're all sick of wasting time looking at them - when people post snippets, particularly when they're militant about not posting the whole program, it's usually not the snippet. It may be the snippet here, but who knows whatall you're doing elsewhere - you could be doing something wrong that could be effecting your code here - for example with how you're defining the global variables, or how you've set the registers elsewhere in the code.

Have you verified the contents of GrblPositionBuffer at the point where the newline is detected? (including checking that there aren't any non-printable characters that you won't see on serial monitor - use something like hterm)

here is the full code.i did verify the contents of buffer it is storing the letters but now that you mention it i dont think the numbers showed up.

CNC-Pendant.ino (14.7 KB)

You have far too much stuff in that ISR. The code in an ISR should complete within a a number of microseconds - 100 µsecs would be very long.

In the function Pc_Write() you have this line

while (!( UCSR0A & (1<<UDRE0)));                // wait while register is free

First, why would you want to wait WHILE it is free.

If you really mean wait UNTIL it is free - first, what is going to clear it while interrupts are disabled and second, how is the delay going to affect the time you are inside the ISR.

And how could we see any of this without the complete program?

...R

it runs flawlessly other than not matching the string i mentioned.

if(GrblSettingsBuffer[2]='3'

Personally I wouldn't use String inside an ISR - I don't think it is re-entrant. I'm not sure about memset either.

Plus what Robin2 said about the ISR being too long. Your main loop doesn't do much. Why can't you set a flag and process the incoming data there? Then you don't need to write your own serial handlers.

bbrown:
im working on a pendant that communicates between Grbl and the pc. its interupt driven so im not using the hardware serial libraries and im having trouble comparing some strings that contain numbers.

What stops you using hardware serial libraries when using interrupts. I use both interrupts and the serial library in just about every project without any problems.

bbrown:
it runs flawlessly other than not matching the string i mentioned.

Perhaps that is because you have now reached the limits of an inadequate system?

...R

See reply #7.

stowite:
What stops you using hardware serial libraries when using interrupts. I use both interrupts and the serial library in just about every project without any problems.

+1 This was my first thought when I read the post.