-
Notifications
You must be signed in to change notification settings - Fork 686
Support Bluetooth communcation JerryScript debugger #2633
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
Conversation
29e9714 to
1ec6114
Compare
1ec6114 to
698d9e8
Compare
b64d000 to
1ddda76
Compare
jerry-core/CMakeLists.txt
Outdated
| endif() | ||
|
|
||
| if(FEATURE_BL_DEBUGGER) | ||
| set(FEATURE_DEBUGGER ON) |
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.
Wrong indentation: two spaces are needed
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 the suggested changes
1ddda76 to
d7e045c
Compare
| - sudo apt-get install -q libbluetooth-dev | ||
| - sudo apt-get install -q python-dev | ||
| - pip install --user pylint==1.6.5 | ||
| - pip install --user pybluez |
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.
Why do code smell and style checks need the installation of additional system and python packages?
But if they are needed, the system dependencies should be added to addons.apt.packages.
.travis.yml
Outdated
| install: | ||
| - sudo apt-get install -q libbluetooth-dev | ||
| - sudo apt-get install -q python-dev | ||
| - pip install --user pybluez |
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.
System dependencies should be listed under addons.apt.packages.
Plus, I think the separating empty line should not be removed from between the jobs.
docs/07.DEBUGGER.md
Outdated
|
|
||
| The following arguments must be passed to `tools/build.py`: | ||
|
|
||
| `--jerry-bl-debugger=on` |
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.
I may be wrong but I cannot recall having seen BL as an abbreviation for Bluetooth. I've only seen BT for Bluetooth and BLE for Bluetooth Low Energy, but not BL.
jerry-debugger/jerry_client.py
Outdated
| try: | ||
| main() | ||
| except bluetooth.BluetoothError as error_msg: | ||
| ERRNO = int(str(error_msg).split(",")[0].split("(")[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.
This string interpretation looks dangerous as well as superfluous.
BluetoothErroris a subclass ofIOErrorhttps://github.com/pybluez/pybluez/blob/master/bluetooth/btcommon.py#L179socker.erroris also a subclass ofIOErrorhttps://docs.python.org/2/library/socket.html#socket.error , or ofOSErrorhttps://docs.python.org/3.7/library/socket.html#socket.error- In Python 2, both
IOErrorandOSErrorare subclasses ofEnvironmentError, while in Python 3 they are aliases of each other. In both cases, they have anerrnoinstance attribute.
So, a single except handler catching IOError as ... should be enough.
jerry-debugger/jerry_client.py
Outdated
| MSG = str(error_msg) | ||
| if ERRNO == 111: | ||
| sys.exit("Failed to connect to the JerryScript debugger.") | ||
| elif ERRNO == 32 or ERRNO == 104: |
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.
I see that these numeric values are copy-pasted from existing code but are there no symbolic names for these error numbers in the errno module? https://docs.python.org/2/library/errno.html
| CLI_OPT_DEF (.id = OPT_DEBUG_SERVER, .longopt = "start-debug-server", | ||
| .help = "start debug server and wait for a connecting client"), | ||
| CLI_OPT_DEF (.id = OPT_DEBUG_SERVER_TYPE, .longopt = "server-type", .meta = "TYPE", | ||
| .help = "choose a server type (choices : tcp or bluetooth) \ |
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.
I'd suggest prefixing the cli option with debug- as well as the help message (i.e., "debug server type").
jerry-main/main-unix.c
Outdated
| #endif /* JERRY_ENABLE_EXTERNAL_CONTEXT */ | ||
|
|
||
| init_engine (flags, start_debug_server, debug_port); | ||
| init_engine (flags, start_debug_server, debug_server_type,debug_port); |
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.
style: missing space after comma
jerry-main/main-unix.c
Outdated
| } | ||
| else | ||
| { | ||
| printf ("bad argument (tcp or bluetooth)\n"); |
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.
Command line argument validity check should not happen here at init_engine phase anymore. That should already be checked when arguments are processed around case OPT_DEBUG_SERVER_TYPE:.
jerry-main/main-unix.c
Outdated
| static void | ||
| init_engine (jerry_init_flag_t flags, /**< initialized flags for the engine */ | ||
| bool debug_server, /**< enable the debugger init or not */ | ||
| const char *debug_server_type, /**< choose which type or server create */ |
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 argument shouldn't be a string. As all "message transmission interfaces" have the same prototype, I think this function should have a function pointer argument, something like: bool (*jerryx_debugger_transport_create) (uint16_t port). And the call site should pass either jerryx_debugger_tcp_create or jerryx_debugger_bluetooth_create.
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.
I'd also prefer the function pointer argument.
|
|
||
| /* | ||
| * Message transmission interfaces. | ||
| */ |
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.
Don't repeat this comment. Just add the new declaration. The comment marks the beginning of a list. Only this list was one element long, until now.
d7e045c to
beb9720
Compare
jerry-core/CMakeLists.txt
Outdated
|
|
||
| # Enable bluetooth_debugger | ||
| if(FEATURE_BL_DEBUGGER) | ||
| set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_BL_DEBUGGER) |
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.
Cannot this define can be added the same if(FEATURE_BL_DEBUGGER) check above?
| #include "jerryscript-ext/debugger.h" | ||
| #include "jext-common.h" | ||
|
|
||
| #if defined (JERRY_DEBUGGER) && defined (JERRY_BL_DEBUGGER) |
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.
According to the jerry-core/CMakeLists.txt if the JERRY_BL_DEBUGGER is defined JERRY_DEBUGGER must be defined as well, so this check can be simplified.
| */ | ||
| static bool | ||
| jerryx_debugger_bluetooth_send (jerry_debugger_transport_header_t *header_p, /**< bluetooth implementation */ | ||
| uint8_t *message_p, /**< message to be sent */ |
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.
Wrong indentation.
| { | ||
| int err_val = errno; | ||
| jerry_debugger_transport_close (); | ||
| jerryx_debugger_bluetooth_log_error (err_val); |
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.
Each jerry_debugger_transport_close is followed by jerryx_debugger_bluetooth_log_error (err_val). How about adding the logging function to the end of the transport close function? Therefore it would be less function calls.
| if (listen (server_socket, port) == -1) | ||
| { | ||
| close (server_socket); | ||
| jerryx_debugger_bluetooth_log_error(strerror (errno)); |
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.
Missing spaces after each jerryx_debugger_bluetooth_log_error(strerror (errno)) function name.
| bool | ||
| jerryx_debugger_bluetooth_create (uint16_t port) | ||
| { | ||
| JERRYX_ERROR_MSG ("suppoert for Bluetooth debugging is disabled.\n"); |
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.
Typo suppoert
| #else /* !JERRY_DEBUGGER || !JERRY_BL_DEBUGGER */ | ||
|
|
||
| /** | ||
| * Dummy function when debugger is disabluetoothd. |
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.
Kind of interesting word disabluetoothd, but probably a typo.
| 0, | ||
| JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE, | ||
| 0, | ||
| JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE); |
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.
These 4 arguments are misaligned by 1 space.
jerry-main/main-unix.c
Outdated
| static void | ||
| init_engine (jerry_init_flag_t flags, /**< initialized flags for the engine */ | ||
| bool debug_server, /**< enable the debugger init or not */ | ||
| const char *debug_server_type, /**< choose which type or server create */ |
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.
I'd also prefer the function pointer argument.
5c44d06 to
8e3a2ec
Compare
|
@akosthekiss @rerobika Thank you for the review! |
jerry-core/CMakeLists.txt
Outdated
| set(FEATURE_LOGGING_MESSAGE " (FORCED BY STATS OR DUMP)") | ||
| endif() | ||
|
|
||
|
|
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.
Unnecessary new line.
| - pip install --user pylint==1.6.5 | ||
| - pip install --user pybluez | ||
|
|
||
|
|
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.
Is the second new line is necessary?
jerry-ext/CMakeLists.txt
Outdated
| set(DEFINES_EXT ${DEFINES_EXT} JERRY_BT_DEBUGGER) | ||
| endif() | ||
|
|
||
|
|
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.
Ditto.
| bool | ||
| jerryx_debugger_bt_create (uint16_t port) /**< listening port */ | ||
| { | ||
|
|
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.
Ditto.
|
|
||
| if (port > 30) | ||
| { | ||
| JERRYX_DEBUG_MSG ("bluetooth port range is 1-30\n"); |
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.
If the error message is correct, this check accepts the 0 port which is misleading.
| } /* jerryx_debugger_bt_create */ | ||
|
|
||
| #else /* !JERRY_BT_DEBUGGER */ | ||
|
|
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.
Unnecessary new line.
jerry-main/main-unix.c
Outdated
| { | ||
| if (check_feature (JERRY_FEATURE_DEBUGGER, cli_state.arg)) | ||
| { | ||
| const char * temp = cli_consume_string (&cli_state); |
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.
const char * temp -> const char *temp
| const char * temp = cli_consume_string (&cli_state); | ||
| if (strcmp (temp, "bluetooth") == 0) | ||
| { | ||
| debug_port = 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.
If the port is hard coded the check above for it could be an assert instead.
Documentation can be found in 07.DEBUGGER.md JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu
8e3a2ec to
6e34cfb
Compare
Documentation can be found in 07.DEBUGGER.md
JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu