Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Finding errors without a simulator (Oshonsoft)

camerart

Well-Known Member
Hi,

I'm checking a routine in my CODE that checks serial input sentences.
A sentence could look like this: $ROBI,111,1,11,W or
this: $GNRMC,111111.00,A,3723.02837,N,00150.39853,W,0.820,188.36,110706,,,A*74
So all of them start with a $ then some CHARs
If an error sentence was used, this could cause a catastrophe.

The routine I'm checking looks for the $ and the first few CHARs and compares them with the $CHARs expected.
I have a mate who is helping me, and he doesn't use the SIM, where I have to.
Using the SIM, I sent a long string of sentences, all with incrementing DATA but some with CHAR errors, and found the error in the routine, and corrected it, so it rejects the error sentences.

The error I found was a sort of negative one, where, as it would be rare to receive an error sentence, they would be passed.
My question is, how does a none SIM user check CODE like this?
Camerart.
 
I think I understand the concept, keep in mind that I read first and then use machine translation to compare.

Although these are very simple algorithms, they can be based on very basic internal concepts that the programmer does not explain. If these concepts are not understood, the algorithm may have a few lines but it seems more complicated than it is. Could you be referring to this?.
 
I think I understand the concept, keep in mind that I read first and then use machine translation to compare.

Although these are very simple algorithms, they can be based on very basic internal concepts that the programmer does not explain. If these concepts are not understood, the algorithm may have a few lines but it seems more complicated than it is. Could you be referring to this?.
Hi D,
I'm not referring to the CODEs you posted, but finding errors in any CODE, e,g, see #1.
C
 
I don't know if I understood correctly.
I work with teams that supply nmea chains, these chains are assumed to be correct, you just have to check the checksum to know if they arrived correctly. When I say correct I mean that they comply with the regulations. The one who receives it is the one who must process them. For this you must wait for the header, in this case $ command + information * checksum. Therefore, the recipient must know what he expects and in what format to be able to carry out the interpretation algorithm.

I have made some automations that receive or send these frames but I have only limited myself to repeating them. I just needed to know when they start and when they end, if they are correct or not, I don't care because the teams that receive them are the ones that interpret them.
If their structure is not correct, it is the software of these computers that decides whether to interpret it or discard it.

It is this?.
 
So to know if a structure is correct or not, apart from checking the checksum, the algorithm has to check the rules of its internal structure. And for each command there are similar, but these are not the same.
This greatly increases the need for post-processing, and therefore the increase in system resources.
 
Last edited:
When going through CODE, I get side tracked sometimes, and loose my place, and have difficulty proof reading backwards and forwards, especially with similar named variables.

Comment everything! Add descriptions and explanations of what things do, to the program, as you write it.

The compiler will ignore comments marked as such in the appropriate way so they do not affect the size of the final program in the MCU.

For Oshonsoft, you apparently start a comment with a single quote - in fact Dogflu has used them in his routines, looking back at those.

It's not unusual for program source files to have more comment lines that actual program statements.
 
So to know if a structure is correct or not, apart from checking the checksum, the algorithm has to check the rules of its internal structure. And for each command there are similar, but these are not the same.
This greatly increases the need for post-processing, and therefore the increase in system resources.
Hi D,
Ok, I will look deeper into string errors and checksums, when I get chance.

My original question is about finding errors in any CODE. I think the next post cover this?
C
 
Comment everything! Add descriptions and explanations of what things do, to the program, as you write it.

The compiler will ignore comments marked as such in the appropriate way so they do not affect the size of the final program in the MCU.

For Oshonsoft, you apparently start a comment with a single quote - in fact Dogflu has used them in his routines, looking back at those.

It's not unusual for program source files to have more comment lines that actual program statements.
Hi R,
I add comments as much as I can, but sometimes there's a bit too much to read, so it may get skipped.

The CODE I'm checking at the moment checks a known string e,g, GNRMC (as in NMEA) against the incoming sentence CHARS.
The CODE that was written for me used ARGS and ARGB as it's 2x comparisons, because it was a procedure, and used by more than one comparison. ARGS and ARGB annoyed me a lot, so, as now there is only one comparison, I re-named them what I think they are gnrmc_str_char and gnrmc_buf_char, which now doesn't annoy me (some strange people about!) We'll see if this helps and allows me to find the error.
C
 

Latest threads

New Articles From Microcontroller Tips

Back
Top