wjasper / Linux_Drivers

Open source Linux device drivers
GNU General Public License v3.0
111 stars 64 forks source link

modified test-E-TC looped read value error #20

Closed sammym1725 closed 6 years ago

sammym1725 commented 6 years ago

I tried to insert a loop so the temperature can display continuous reads but i goes well for a while and later sends an error as follows Program insert looks like this>>> try: while True:

Pause the loop first

       #time.sleep(0.25)
       for i in range(nchan):
         time.sleep(1) 
         TimeStamp = time.asctime(time.localtime(time.time()))
         etc.TinConfig_W()
         etc.TinConfig_R()
         temperature = etc.Tin(channel, CELSIUS, i-1) 
         print(TimeStamp, '  Channel = ',i,'  Temperature = ',temperature[i],'C  ')
  except KeyboardInterrupt:
    pass

Error msg >>> Traceback (most recent call last): File "test-E-TCxx.py", line 205, in main() File "test-E-TCxx.py", line 186, in main etc.TinConfig_W() File "/home/pi/Downloads/Linux_Drivers-master/Ethernet/python/E_TC.py", line 618, in TinConfig_W s_buffer[MSG_INDEX_FRAME] = self.device.frameID ValueError: byte must be in range(0, 256)

How can I get a continuous read with time stamp but avoiding the ValueError problem.

wjasper commented 6 years ago

I think I see the problem. The frame index is only 1 byte so after a while it got overflowed (in python). Simple fix, need to mod 256 so it wraps around.

sammym1725 commented 6 years ago

Hi Warren J, Sorry but just to understand what you meant. Is your suggestion to add % 256 in the program line >>> temperature = etc.Tin(channel, CELSIUS, i-1) % 256 Ran this and it had another error. Still trying out new things in python and my language familiarity is still low. I appreciate if you would indicate where can I put the mod256 to avoid the ValueError. Thanks

wjasper commented 6 years ago

Issue fixed. Just do a "git pull"