-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add simulator #253
Add simulator #253
Conversation
tACK |
src/simulator.c
Outdated
exit(1); | ||
} | ||
} | ||
} |
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.
Small nit: Some compilers complain about not having a newline.
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.
My local build environment (OSX, clang) does complain and aborts the build here. Would appreciate a newline.
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.
Fixed
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.
Thanks a lot @achow101 !
This is great. I added some small nits in the review.
CMakeLists.txt
Outdated
set(ELF ${MYPROJECT}.elf) | ||
set(CMAKE_TOOLCHAIN_FILE arm.cmake) | ||
include(${CMAKE_TOOLCHAIN_FILE}) | ||
elseif(BUILD_TYPE STREQUAL "simulator") | ||
set(ELF ${MYPROJECT}) |
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.
This is not necessary and can be deleted. Elf files are only used in firmware builds.
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.
Done
src/simulator.c
Outdated
exit(1); | ||
} | ||
} | ||
} |
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.
My local build environment (OSX, clang) does complain and aborts the build here. Would appreciate a newline.
src/sd.c
Outdated
void set_root_dir(const char* path, size_t path_len) | ||
{ | ||
memset(ROOTDIR, 0, 256); | ||
memcpy(ROOTDIR, path, path_len); |
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.
nit:
It is not so important since it is a simulator, but instead of memcpy, using:
snprintf(ROOTDIR, sizeof(ROOTDIR), "%s", path);
protects against potential buffer overflows. path_len
would then not be needed.
(Also in the line above, a sizeof(ROOTDIR)
is preferred over 256
.)
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.
Done
0b870d8 Document how to build the simulator (Andrew Chow) 8f1dff2 Change Digital Bitbox test to use simulator (Andrew Chow) 07c9771 Build digital bitbox simulator in setup_environment.sh (Andrew Chow) 814d02d Implement support for communicating with a dbb simulator (Andrew Chow) Pull request description: This PR changes the current manual Digital Bitbox tests into an automated test. This uses the [simulator that I wrote](https://github.com/achow101/mcu/blob/simulator/src/simulator.c) (which is also [PR'd](BitBoxSwiss/mcu#253) to Digital Bitbox). Built on #104 Tree-SHA512: 582afa5e045c1e222064958b1b9dda17db7025dd5ff3f8a64a826abe92631b0dd808fcded501bedec7fc1d8ef4c386c99212ff1b182d149e182ea472f65d92ea
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.
tACK
This PR adds a simulator for the Digital Bitbox. The simulator binds to port 35345 and listens for UDP packets. Whatever it receives is passed directly to the commander as what it receives should be exactly the command string that the commander needs. The response is then sent back to the sender using UDP. For the files in the sd card, the simulator requires that the path to the location for the fake sd card folder is specified when the simulator is started.
To build the simulator, an additional build type is added.
cmake
must use thesimulator
build type so that the simulator is built.Closes #252