Skip to content

Commit

Permalink
fixes around frame sending
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Apr 28, 2023
1 parent 92620b0 commit 81547c8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
23 changes: 19 additions & 4 deletions cli/src/cli.ts
Expand Up @@ -151,12 +151,16 @@ export async function mainCli() {
"use tcp jacdac proxy on 127.0.0.1:8082 (otherwise ws://127.0.0.1:8081)"
)
.option("-t, --test", "run in test mode (no sockets, no restarts)")
.option("-k, --test-self-exit", "let the test code exit the process (keep-running)")
.option(
"-k, --test-self-exit",
"let the test code exit the process (keep-running)"
)
.option(
"-T, --test-timeout <milliseconds>",
"set timeout for --test mode (default: 2000ms)"
)
.option("-w, --wait", "wait for external deploy")
.option("--device-id <string>", "set device ID")
.arguments("[file.ts|file.devs]")
.action(runScript)

Expand Down Expand Up @@ -201,7 +205,10 @@ export async function mainCli() {
"-s, --serial <serial-port>",
"connect to serial port, not 127.0.0.1:8082"
)
.option("-k, --test-self-exit", "let the test code exit the process (keep-running)")
.option(
"-k, --test-self-exit",
"let the test code exit the process (keep-running)"
)
.arguments("<file.ts|file.devs>")
.action(crunScript)

Expand Down Expand Up @@ -340,8 +347,16 @@ export async function mainCli() {

program
.command("snippets", { hidden: true })
.option("--include <pattern>", "include given files", "website/**/*.{md,mdx}")
.option("--exclude <pattern>", "exclude given files", "website/**/api/clients/*.md")
.option(
"--include <pattern>",
"include given files",
"website/**/*.{md,mdx}"
)
.option(
"--exclude <pattern>",
"exclude given files",
"website/**/api/clients/*.md"
)
.description("compile devs snippets")
.action(snippets)

Expand Down
6 changes: 5 additions & 1 deletion runtime/devicescript/devsmgr.c
Expand Up @@ -434,6 +434,7 @@ void devsmgr_handle_packet(srv_t *state, jd_packet_t *pkt) {
state->running = 0; // not running yet
try_run(state);
} else if (!state->running && state->ctx) {
LOG("running set to false");
stop_program(state);
}
break;
Expand Down Expand Up @@ -517,7 +518,10 @@ void devs_service_full_init(const devsmgr_cfg_t *cfg) {
#endif

#if JD_NETWORK
if (!dcfg_get_bool("devNetwork")) {
if (dcfg_get_bool("devNetwork")) {
LOG("devNetwork mode - disable cloud adapter");
} else {
LOG("starting cloud adapter");
#if JD_WIFI
wifi_init();
#endif
Expand Down
4 changes: 2 additions & 2 deletions runtime/devicescript/jdiface.c
Expand Up @@ -583,8 +583,8 @@ __attribute__((weak)) uint64_t devs_jd_server_device_id(void) {

bool jd_need_to_send(jd_frame_t *f) {
// no need to send packets to/from ourselves on the SWS wire
if (f->device_identifier == jd_device_id() ||
f->device_identifier == devs_jd_server_device_id())
if (((jd_packet_t *)f)->service_command && (f->device_identifier == jd_device_id() ||
f->device_identifier == devs_jd_server_device_id()))
return false;
return true;
}
3 changes: 3 additions & 0 deletions runtime/inc/jd_user_config.h
Expand Up @@ -44,4 +44,7 @@ extern const uint8_t jd_dcfg_array[];

#define JD_NETWORK 1

int tx_send_frame(void *frame);
#define JD_USB_BRIDGE_SEND(f) tx_send_frame(f)

#endif
2 changes: 1 addition & 1 deletion runtime/jacdac-c
Submodule jacdac-c updated 1 files
+21 −3 inc/jd_config.h
13 changes: 9 additions & 4 deletions runtime/posix/tx.c
Expand Up @@ -18,13 +18,18 @@ void jd_packet_ready(void) {
}

void tx_process(void) {
// just empty the queue - we do not have SWS
while (packet_ready) {
packet_ready = 0;
jd_frame_t *f = jd_tx_get_frame();
if (f) {
if (transport)
transport->send_frame(transport_ctx, f);
if (f)
jd_tx_frame_sent(f);
}
}
}

int tx_send_frame(void *frame) {
// the real transport is plugged in place of USB
if (transport)
return transport->send_frame(transport_ctx, frame);
return -1;
}

0 comments on commit 81547c8

Please sign in to comment.