Skip to content

Commit

Permalink
fix bug: send wrong frame
Browse files Browse the repository at this point in the history
  • Loading branch information
timercrack committed Jan 18, 2016
1 parent 428685c commit d30fbb6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pydatacoll/protocols/iec104/device.py
Expand Up @@ -276,7 +276,8 @@ async def handle_i(self, frame):
data_pairs.add((data_time, data_addr, data.value))
method = 'call' if frame.ASDU.Cause == Cause.req else \
'ctrl' if frame.ASDU.Cause == Cause.actcon else 'data'
logger.debug('device[%s] method=%s, data_pairs=%s', self.device_id, method, data_pairs)
logger.debug('device[%s] method=%s, data_pairs=%s', self.device_id, method, [
"{time} {data[1]} {data[2]}".format(time=data[0].isoformat(),data=data) for data in data_pairs])
await self.process_data(data_pairs, method)
elif frame.ASDU.Cause == Cause.actcon:
if TYP.C_SC_NA_1 <= frame.ASDU.TYP <= TYP.C_SE_TC_1 and frame.ASDU.data[0].se == 1:
Expand Down Expand Up @@ -428,7 +429,7 @@ def fresh_task(self, term_dict, term_item_dict, delete=False):
pass

def prepare_call_frame(self, term_item_dict):
frame = iec_104.init_frame(self.ssn, self.rsn, TYP.C_RD_NA_1, Cause.act) # 102 读命令
frame = iec_104.init_frame(self.ssn, self.rsn, TYP.C_RD_NA_1, Cause.req) # 102 读命令
frame.ASDU.data[0].address = int(term_item_dict['protocol_code'])
return frame

Expand Down

0 comments on commit d30fbb6

Please sign in to comment.