@@ -87,6 +87,45 @@ def testGetCommEventLogWithEvents(self):
8787 self .assertEqual (response .event_count , 0x12 )
8888 self .assertEqual (response .events , [0x12 ,0x34 ,0x56 ])
8989
90+ def testReportSlaveIdRequest (self ):
91+ with mock .patch ("pymodbus.other_message.DeviceInformationFactory" ) as dif :
92+ # First test regular identity strings
93+ identity = {
94+ 0x00 : 'VN' , # VendorName
95+ 0x01 : 'PC' , # ProductCode
96+ 0x02 : 'REV' , # MajorMinorRevision
97+ 0x03 : 'VU' , # VendorUrl
98+ 0x04 : 'PN' , # ProductName
99+ 0x05 : 'MN' , # ModelName
100+ 0x06 : 'UAN' , # UserApplicationName
101+ 0x07 : 'RA' , # reserved
102+ 0x08 : 'RB' , # reserved
103+ }
104+ dif .get .return_value = identity
105+ expected_identity = "-" .join (identity .values ()).encode ()
106+
107+ request = ReportSlaveIdRequest ()
108+ response = request .execute ()
109+ self .assertEqual (response .identifier , expected_identity )
110+
111+ # Change to byte strings and test again (final result should be the same)
112+ identity = {
113+ 0x00 : b'VN' , # VendorName
114+ 0x01 : b'PC' , # ProductCode
115+ 0x02 : b'REV' , # MajorMinorRevision
116+ 0x03 : b'VU' , # VendorUrl
117+ 0x04 : b'PN' , # ProductName
118+ 0x05 : b'MN' , # ModelName
119+ 0x06 : b'UAN' , # UserApplicationName
120+ 0x07 : b'RA' , # reserved
121+ 0x08 : b'RB' , # reserved
122+ }
123+ dif .get .return_value = identity
124+
125+ request = ReportSlaveIdRequest ()
126+ response = request .execute ()
127+ self .assertEqual (response .identifier , expected_identity )
128+
90129 def testReportSlaveId (self ):
91130 with mock .patch ("pymodbus.other_message.DeviceInformationFactory" ) as dif :
92131 dif .get .return_value = dict ()
0 commit comments