Skip to content

The ENES100.mission() needs clearer code and improved documentation #16

@briandk

Description

@briandk

Problem - The mission() function documentation isn't clear

The documentation for ENES100.mission() looks like this:

Valid calls for **DATA**:
* `Enes100.mission(CYCLE, x);` *x is the duty cycle percent (ex. 10, 30, 50, 70, 90)*
* `Enes100.mission(MAGNETISM, MAGNETIC);`
* `Enes100.mission(MAGNETISM, NOT_MAGNETIC);`

What's not clear is how many arguments (and of what type) each function takes. Does Enes100.mission(CYCLE, x); take one argument x, whose meaning is the duty cycle? Or does it take two arguments? And if it takes two, what types are the arguments?

Also, why should students use the mission() function instead of just printing to the serial monitor directly?

As I show below, confusion over what arguments (and what types) the mission() function takes matters, because the arguments determine which version of mission() gets dispatched

The ENES100.mission() function actually seems to use polymorphic dispatch

Here's one version of the function that takes two ints as arguments:

bool VisionSystemClient::mission(int type, int message) {
mSerial->write(OP_MISSION);
mSerial->write(type);
mSerial->print(message);
mSerial->write(FLUSH_SEQUENCE, 4);
mSerial->flush();
return receive(NULL);
}

And here's another that takes an int and a char:

bool VisionSystemClient::mission(int type, char message) {
mSerial->write(OP_MISSION);
mSerial->write(type);
mSerial->print(message);
mSerial->write(FLUSH_SEQUENCE, 4);
mSerial->flush();
return receive(NULL);
}

A user shouldn't have to know which version of the function gets dispatched , but students are getting very confused about how many arguments they're supposed to provide to mission() and what types those arguments should be.

Proposed Solution

We should at least be using syntax-colored fenced code blocks to document function calls.

So,

```ino
ENES100.mission(int type, char message)
```

becomes

ENES100.mission(int type, char message);

Questions

  1. Why do we have multiple versions of ENES100.mission()?
  2. Why don't students just use a basic print command to print to the serial monitor?
  3. Can we implement fenced code blocks in the README to make documentation clearer?

/cc @itsecgary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions