Skip to content

Commit

Permalink
modbus tcp dont queue when sock not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
salhk committed Sep 21, 2023
1 parent 1205ce9 commit 227dd07
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modbus/modbus.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ sub modbus_master_send_next()
modbus_debug_print("send " + tmp)
#endif

modbus_request_queue(modbus_queue_start).timestamp=sys.timercountms
if modbus_request_queue(modbus_queue_start).protocol=modbus_TCP then
prev_num=sock.num
sock.num=modbus_request_queue(modbus_queue_start).interface_number
Expand All @@ -399,7 +400,7 @@ sub modbus_master_send_next()
ser.notifysent(ser.txbuffsize-len(data))
ser.num=prev_num
end if
modbus_request_queue(modbus_queue_start).timestamp=sys.timercountms

' modbus_debug_print("sent for " + str(modbus_request_queue(modbus_queue_start).device_id))

modbus_master_recv_buffer=""
Expand Down Expand Up @@ -585,6 +586,12 @@ sub modbus_queue_clear()
end sub

sub modbus_queue_add(request_item as modbus_request_item)
if request_item.protocol=modbus_RTU then
sock.num=request_item.interface_number
if sock.statesimple <> PL_SSTS_EST then
exit sub
end if
end if
' cut in line if request is write
' loop through current queue and find first read request of same device
' replace with write request
Expand Down

0 comments on commit 227dd07

Please sign in to comment.