feat: modbus

This commit is contained in:
dawnwinterLiu 2024-06-04 17:31:14 +08:00
parent ebfff50eba
commit f5a0266534

View File

@ -74,7 +74,7 @@ handle_info({tcp, Buff}, #dclient{channel = ChannelId,
EndData = <<OldData/binary, Data/binary>>, EndData = <<OldData/binary, Data/binary>>,
%% io:format("~s ~p EndData = ~p.~n", [?FILE, ?LINE, dgiot_utils:binary_to_hex(EndData)]), %% io:format("~s ~p EndData = ~p.~n", [?FILE, ?LINE, dgiot_utils:binary_to_hex(EndData)]),
AllData = modbus_tcp:parse_frame(StartAddr, FileName, EndData, MinAddr), AllData = modbus_tcp:parse_frame(StartAddr, FileName, EndData, MinAddr),
dgiot_data:insert({check_connection, ChannelId, FileName}, dgiot_datetime:now_secs()), dgiot_data:insert({check_connection, dgiot_utils:to_binary(ChannelId), FileName}, dgiot_datetime:now_secs()),
dgiot_bridge:send_log(dgiot_utils:to_binary(ChannelId), "~p recv data ~ts => ~p", [dgiot_datetime:format("YYYY-MM-DD HH:NN:SS"), unicode:characters_to_list(dgiot_json:encode(AllData)), dgiot_utils:binary_to_hex(EndData)]), dgiot_bridge:send_log(dgiot_utils:to_binary(ChannelId), "~p recv data ~ts => ~p", [dgiot_datetime:format("YYYY-MM-DD HH:NN:SS"), unicode:characters_to_list(dgiot_json:encode(AllData)), dgiot_utils:binary_to_hex(EndData)]),
erlang:send_after(Freq * 1000, self(), read), erlang:send_after(Freq * 1000, self(), read),
{noreply, Dclient#dclient{child = ChildState#{di => StartAddr, data => <<>>}}}; {noreply, Dclient#dclient{child = ChildState#{di => StartAddr, data => <<>>}}};