Skip to content

Commit c2e099d

Browse files
committed
Fix i2c and spi esp32 drivers with ports
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 44191fc commit c2e099d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/platforms/esp32/components/avm_builtins/gpio_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,11 @@ static term gpiodriver_set_int(Context *ctx, int32_t target_pid, term cmd)
463463
term trigger = term_get_tuple_element(cmd, 2);
464464
if (term_get_tuple_arity(cmd) == 4) {
465465
term pid = term_get_tuple_element(cmd, 3);
466-
if (UNLIKELY(!term_is_pid(pid) && !term_is_atom(pid))) {
466+
if (UNLIKELY(!term_is_local_pid(pid) && !term_is_atom(pid))) {
467467
ESP_LOGE(TAG, "Invalid listener parameter, must be a pid() or registered process!");
468468
return ERROR_ATOM;
469469
}
470-
if (term_is_pid(pid)) {
470+
if (term_is_local_pid(pid)) {
471471
target_local_pid = term_to_local_process_id(pid);
472472
} else {
473473
int pid_atom_index = term_to_atom_index(pid);

src/platforms/esp32/components/avm_builtins/i2c_driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,8 @@ static NativeHandlerResult i2cdriver_consume_mailbox(Context *ctx)
633633

634634
I2CAcquireResult i2c_driver_acquire(term i2c_port, i2c_port_t *i2c_num, GlobalContext *global)
635635
{
636-
if (UNLIKELY(!term_is_pid(i2c_port))) {
637-
ESP_LOGW(TAG, "acquire: given term is not a PID.");
636+
if (UNLIKELY(!term_is_local_port(i2c_port))) {
637+
ESP_LOGW(TAG, "acquire: given term is not a port.");
638638
return I2CAcquireInvalidPeripheral;
639639
}
640640

@@ -660,7 +660,7 @@ I2CAcquireResult i2c_driver_acquire(term i2c_port, i2c_port_t *i2c_num, GlobalCo
660660

661661
void i2c_driver_release(term i2c_port, GlobalContext *global)
662662
{
663-
if (UNLIKELY(!term_is_pid(i2c_port))) {
663+
if (UNLIKELY(!term_is_local_port(i2c_port))) {
664664
ESP_LOGW(TAG, "release: given term is not a PID.");
665665
return;
666666
}

src/platforms/esp32/components/avm_builtins/socket_driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static void do_connect(Context *ctx, const GenMessage *gen_message)
858858
term active_term = interop_proplist_get_value_default(params, ACTIVE_ATOM, TRUE_ATOM);
859859
term controlling_process_term = interop_proplist_get_value(params, CONTROLLING_PROCESS_ATOM);
860860

861-
bool ok = term_is_pid(controlling_process_term);
861+
bool ok = term_is_local_pid(controlling_process_term);
862862
if (UNLIKELY(!ok)) {
863863
do_send_error_reply(ctx, ERR_ARG, ref_ticks, pid);
864864
return;
@@ -1022,7 +1022,7 @@ void do_udp_open(Context *ctx, const GenMessage *gen_message)
10221022
term active_term = interop_proplist_get_value_default(params, ACTIVE_ATOM, TRUE_ATOM);
10231023
term controlling_process_term = interop_proplist_get_value(params, CONTROLLING_PROCESS_ATOM);
10241024

1025-
bool ok = term_is_pid(controlling_process_term);
1025+
bool ok = term_is_local_pid(controlling_process_term);
10261026
if (UNLIKELY(!ok)) {
10271027
do_send_error_reply(ctx, ERR_ARG, ref_ticks, pid);
10281028
return;
@@ -1369,7 +1369,7 @@ static void do_controlling_process(Context *ctx, const GenMessage *gen_message)
13691369
return;
13701370
}
13711371
term new_pid_term = term_get_tuple_element(gen_message->req, 1);
1372-
if (UNLIKELY(!term_is_pid(new_pid_term))) {
1372+
if (UNLIKELY(!term_is_local_pid(new_pid_term))) {
13731373
do_send_error_reply(ctx, ERR_ARG, ref_ticks, pid);
13741374
} else {
13751375
term return_msg;

src/platforms/esp32/components/avm_builtins/spi_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static NativeHandlerResult spidriver_consume_mailbox(Context *ctx)
677677

678678
bool spi_driver_get_peripheral(term spi_port, spi_host_device_t *host_dev, GlobalContext *global)
679679
{
680-
if (UNLIKELY(!term_is_pid(spi_port))) {
680+
if (UNLIKELY(!term_is_local_port(spi_port))) {
681681
ESP_LOGW(TAG, "Given term is not a SPI port driver.");
682682
return false;
683683
}

0 commit comments

Comments
 (0)