I'm having a bit of a problem trying to figure out how a checksum works on a piece of equipment I'm trying to communicate with. Each message I send to the equipment has a 2 character checksum as the last two characters. The documentation only states that the checksum is "two character checksum, based on all characters after STX".

The message format uses STX to start the message proceeded by the message contents. I have example messages from the documentation and they work but I can't seem to figure out the method to calculate the checksum.

For instance an example message is 01M52 where 52 is the checksum.
Another message is 01I56 where 56 is the checksum.
And finally another 01Q4E where 4E is the checksum.

I've google around and have yet to find anything that results in the correct checksums they provide. The documentation is about useless on the topic. I know the messages work because I get responses based on their examples. Any help on this would be greatly appreciated.

From the limited data this is probably trivial.

int checksum (char * str)
  byte sum = 0 ;
  char ch ;
  while ((ch = *str++) != 0)
    sum -= ch ;
  return sum ;

Thank you, works perfectly.