@@ -314,15 +314,8 @@ def remote_port(self):
314
314
@property
315
315
def ifconfig (self ):
316
316
"""Returns the network configuration as a tuple."""
317
- # set subnet and gateway addresses
318
- self ._pbuff = bytearray (8 )
319
- for octet in range (0 , 4 ):
320
- self ._pbuff += self .read (REG_SUBR + octet , 0x04 )
321
- for octet in range (0 , 4 ):
322
- self ._pbuff += self .read (REG_GAR + octet , 0x04 )
323
-
324
- params = (self .ip_address , self ._pbuff [0 :3 ], self ._pbuff [3 :7 ], self ._dns )
325
- return params
317
+ return (self .ip_address , self .read (REG_SUBR , 0x00 , 4 ),
318
+ self .read (REG_GAR , 0x00 , 4 ), self ._dns )
326
319
327
320
@ifconfig .setter
328
321
def ifconfig (self , params ):
@@ -332,14 +325,10 @@ def ifconfig(self, params):
332
325
"""
333
326
ip_address , subnet_mask , gateway_address , dns_server = params
334
327
335
- # Set IP Address
336
328
self .write (REG_SIPR , 0x04 , ip_address )
329
+ self .write (REG_SUBR , 0x04 , subnet_mask )
330
+ self .write (REG_GAR , 0x04 , gateway_address )
337
331
338
- # set subnet and gateway addresses
339
- for octet in range (0 , 4 ):
340
- self .write (REG_SUBR + octet , 0x04 , subnet_mask [octet ])
341
- self .write (REG_GAR + octet , 0x04 , gateway_address [octet ])
342
- # set dns server address
343
332
self ._dns = dns_server
344
333
345
334
def _w5100_init (self ):
0 commit comments