NebraLtd / hm-pktfwd

Helium Miner Packet Forwarder
https://nebra.io/hnt
MIT License
12 stars 25 forks source link

str() function on a string? #21

Closed shawaj closed 3 years ago

shawaj commented 3 years ago

When fixing some stuff in light-hotspot-software, I came across this:

https://github.com/NebraLtd/hm-pktfwd/blob/34e6a417039956404bbcab97ecf215e0efbd7872/files/configurePktFwd.py#L16-L19

The reset and spi_bus were back to front.

I have corrected it this:

https://github.com/NebraLtd/hm-pktfwd/blob/4216b49f982690228fc1e361c4ff3550a5195808/files/configurePktFwd.py#L16-L19

However due to my limited knowledge of code, I just wanted to get a sense check @vpetersson ... basically, I thought the str(spi_bus) was somewhat pointless as it is already a string? I am guessing the str() function was meant to be used for the reset_pin variable as that is a number?

vpetersson commented 3 years ago

Would be better to rewrite it as follows:

 spi_bus = variant_variables['SPIBUS'] 
 print("Hardware Variant {} detected".format(variant)) 
 print("RESET: {}.".format(reset_pin)) 
 print("SPI: {}".format(spi_bus))

This is usually how you write it in Python 3 style. The other way is more how you wrote it in Python 2.7.

shawaj commented 3 years ago

corrected in d29648e40d7d4c3d15389a425523ca45dd4c6350