Skip to content

Commit

Permalink
Fix for issue #9.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Jun 16, 2022
1 parent 321150a commit 2a9f46f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,12 @@ bool modbus_send (modbus_message_t *msg, const modbus_callbacks_t *callbacks, bo

bool poll = true;

grbl.on_execute_realtime(state_get());

while(state != ModBus_Idle) {

grbl.on_execute_realtime(state_get());
if(ABORTED)
if(sys.abort)
return false;
}

Expand All @@ -302,7 +305,7 @@ bool modbus_send (modbus_message_t *msg, const modbus_callbacks_t *callbacks, bo

grbl.on_execute_realtime(state_get());

if(ABORTED)
if(sys.abort)
poll = false;

else switch(state) {
Expand Down Expand Up @@ -353,14 +356,19 @@ static void modbus_reset (void)
{
while(spin_lock);

packet = NULL;
tail = head;
if(sys.abort) {

packet = NULL;
tail = head;

silence_until = 0;
state = ModBus_Idle;

silence_until = 0;
state = ModBus_Idle;
stream.flush_tx_buffer();
stream.flush_rx_buffer();

stream.flush_tx_buffer();
stream.flush_rx_buffer();
} else while(state != ModBus_Idle)
modbus_poll();

driver_reset();
}
Expand Down Expand Up @@ -439,7 +447,7 @@ static void onReportOptions (bool newopt)
on_report_options(newopt);

if(!newopt)
hal.stream.write("[PLUGIN:MODBUS v0.12]" ASCII_EOL);
hal.stream.write("[PLUGIN:MODBUS v0.13]" ASCII_EOL);
}

bool modbus_isup (void)
Expand Down

0 comments on commit 2a9f46f

Please sign in to comment.