I finally had time to peruse the source and have a couple of comments.
These comments apply especially to new programmers.
Firstly I think the code looks solid, I have no issues there.
There is one error though
When describing how #include files work. It's not really like that.
The Code warrior help says this;
*Note that both styles cause the directive (#include) to be replaced by the entire contents of the file, not just the quoted version..
The search for include files is governed by two environment variables: GENPATH: #include "File" Path and LIBRARYPATH: 'include <File>' Path.
Include files that are included using double quotes as in:
#include "test.h"
are searched first in the current directory, then in the directory specified by the -I: Include File Path option,
then in the directories given in the GENPATH: #include "File" Path environment variable, and finally in those listed in the LIBPATH or
LIBRARYPATH: 'include <File>' Path environment variable. The current directory is set using the IDE, the Program Manager, or
the DEFAULTDIR: Default Current Directory environment variable.
Include files that are included using angular brackets as in
#include <stdio.h>
are searched for first in the current directory, then in the directory specified by the -I option, and then
in the directories given in LIBPATH or LIBRARYPATH. The current directory is set using the IDE, the Program Manager, or
the DEFAULTDIR environment variable.
My main issue is mostly style, or lack of it.
Or is it that every possible style seems to be used?
I'm not objecting to the bracket placement as that is a personal preference issue
ie.
But rather the lack of vertical whitespace, the random breaking of lines and the inconsistent style.
When you modify code that someone else has written, suck it up and use their style.
Put a blank line before and after logical blocks of code, like an if, while or just a group of variables that are related.
Crunching everything together does not make you code smaller, the compiler doesn't care
indent!
reverse or random indenting makes reading the code hard. Clean consistent indenting makes life SO much easier esp when reviewing new code or code you haven't seen in a year.
Which is easier to read;
This
Code: Select all
switch(txmode){
case 0:
switch(SCI0DRL){
case 'a': // send back all real time ram output variables
next_txmode = 1;
txmode = getCANid;
cksum = 0;
break;
case 'w': // receive new ram input data and write into offset location;
// also used for forwarding CAN msgs bet. MT & auxilliary boards.
// In this CAN mode, no_bytes must be >0 and <=8.
next_txmode = 5;
txmode = getCANid;
rd_wr = 1;
break;
case 'e': // same as 'w', but verify by echoing back values. Don't use with CAN
next_txmode = 5;
txmode = getCANid;
rd_wr = 2;
break;
...
or
Code: Select all
switch(txmode)
{
case 0:
switch(SCI0DRL)
{
case 'a': // send back all real time ram output variables
next_txmode = 1;
txmode = getCANid;
cksum = 0;
break;
case 'w': // receive new ram input data and write into offset location;
// also used for forwarding CAN msgs bet. MT & auxilliary boards.
// In this CAN mode, no_bytes must be >0 and <=8.
next_txmode = 5;
txmode = getCANid;
rd_wr = 1;
break;
case 'e': // same as 'w', but verify by echoing back values. Don't use with CAN
next_txmode = 5;
txmode = getCANid;
rd_wr = 2;
break;
Tabs vs Spaces cause many a holy war, but everyone agrees that mixing them is bad, Stick with what you started with!
Hope this isn't too much of a rant!
Keith