-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Examples): Add CLI Library to MSDK #679
feat(Examples): Add CLI Library to MSDK #679
Conversation
/clang-format-run |
Libraries/CLI/src/cli.c
Outdated
//Find end of string | ||
for (end = input; *end != '\0'; end++) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion here,
Instead of using a for loop, you can use strlen(), that would give the number of characters in the input buffer. Then you can do pointer arithmetic to find the end ptr.
Libraries/CLI/src/cli.c
Outdated
// Handle Enter or carriage return | ||
MXC_UART_WriteCharacter(MXC_UART_GET_UART(CONSOLE_UART), NEW_LINE); | ||
MXC_UART_WriteCharacter(MXC_UART_GET_UART(CONSOLE_UART), ENTER); | ||
buf[idx++] = '\r'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a carriage return in this line?
Because I see in the process command we are looking for a NULL terminated char pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line accumulator here enters a '\r' character every time the enter key is pressed by the user.
Later the process_command function looks for carriage return while iterating over each character in the input command to check the end of the string and break from the iterating for loop.
Libraries/CLI/src/cli.c
Outdated
//Iterate over each character in input | ||
for (p = input; p < end; p++) { | ||
//If in a token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of iterating over all characters in the array, I would suggest using strchr() function, search for white_space, then create argv[][] array with all arguments given by the user. I think that could be computationally efficient.
/clang-format-run |
Examples/MAX78000/SDHC_FTHR/Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default board is the FTHR_RevA for the SDHC example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will merge once final checks pass
Co-authored-by: Suraj-Ajjampur <suraj.ajjampur@analog.com> Co-authored-by: Suraj-Ajjampur <Suraj-Ajjampur@users.noreply.github.com> Co-authored-by: Scheiffler <Jacob.Scheiffler@analog.com> Co-authored-by: Jacob Scheiffler <86001820+Jacob-Scheiffler@users.noreply.github.com> Co-authored-by: Jake Carter <Jake.Carter@analog.com>
Description
Requirements captured during functional testing of MAX78000 Examples. Ticket - MSDK-1197
Features added
This implementation has been exported as a library as all clients can export this cli implementation and provide an isolation of functionality. This design is suited to be retrofitted to different CLI implementations as different arguments of a function which are separated as tokens can be passed in through the handler function.