Comment 6 for bug 839082

Revision history for this message
Christian Hintze (hintze) wrote : Re: [Bug 839082] Re: Data couldn't be retrieved from Watch

hi, yeah actually were germans and we can communicate in our language
therefor. but i would prefer to make the public communication in this
place international.

so what i see so far, the problem is located in the line

"data = ser.read(64)"

could you try to change 64 to, say 128? you had too much data points,
they couldnt fit into 64 characters. i thought we did change that
allready. but im a little bit confused :D if you do have that much
data now, than you can try if it works. but im sure that this is the
cause of the bug here.

2011/9/4 Stefan Willems <email address hidden>:
> Hi,
>
> today I was able to debug a little:
>
> Script says this:
>
> Lade Daten von der Uhr herunter...
> Uhr benutzt Protokoll V1
> V1
> 0
> 23
> 1
> 32
> 1
> 41
> 2
> 13
> 2
> 21
> 2
> 58
> 3
> 10
> 3
> 20
> 3
> 40
> 4
> 4
> 4
> 17
> 4
> 36
> 4
> 48
> 5
> 25
> 5
> 47
> 6
> 16
> 6
>
> After putting it in a readable format:
>
> Lade Daten von der Uhr herunter...
> Uhr benutzt Protokoll V1
> V1
> 0:23
> 1:32
> 1:41
> 2:13
> 2:21
> 2:58
> 3:10
> 3:20
> 3:40
> 4:4
> 4:17
> 4:36
> 4:48
> 5:25
> 5:47
> 6:16
> 6
>
> ...and fillig it up with data directly from the watch:
>
> Lade Daten von der Uhr herunter...
> Uhr benutzt Protokoll V1
> V1
> 0:23
> 1:32
> 1:41
> 2:13
> 2:21
> 2:58
> 3:10
> 3:20
> 3:40
> 4:4
> 4:17
> 4:36
> 4:48
> 5:25
> 5:47
> 6:16
> 6
>
>
> 6:33
> 6:45
> 7:13
> 7:32
> 8:01
>
> Data A 22:55
>
> After modifying communication.py:
>    print "Read 64"
>    ser.write('V')
>    data = ser.read(64)
>    for i in range(len(data)):
>        print ord(data[i])
>        dat.append(data[i])
>
> Lade Daten von der Uhr herunter...
> Read 64
> 86
> 9
> 4
> 0
> 20
> 0
> 0
> 8
> 30
> 21
> 0
> 23
> 49
> 1
> 32
> 52
> 1
> 41
> 37
> 2
> 13
> 16
> 2
> 21
> 25
> 2
> 58
> 1
> 3
> 10
> 16
> 3
> 20
> 37
> 3
> 40
> 25
> 4
> 4
> 55
> 4
> 17
> 52
> 4
> 36
> 4
> 4
> 48
> 46
> 5
> 25
> 16
> 5
> 47
> 43
> 6
> 16
> 46
> 6
> 33
> 34
> 6
> 45
> 40
> Uhr benutzt Protokoll V1
> V1
> 0
> 23
> 52
> 1
> 13
> 16
> 2
> 58
> 16
> 3
> 40
> 25
> 4
> 17
> 4
> 4
> 25
> 16
> 6
> 16
>
> Übertrage Daten zum Browser...
>
>
> Hmm...
>
> greetings,
> Stefan
>
> PS: Is german your native language? If, we can talk in german, that's
> easier.
>
> Am Freitag, den 02.09.2011, 07:41 +0000 schrieb hintze:
>> ok. thank you very much for your offer :) i would appreciate if you
>> could provide some debugging. ok ill try to explain the communication in
>> some short sentences.
>>
>> first of all, the watches communicate with your PC by an USB-serial-adapter, which is located inside the clamb you use to attach your watch. with some really basic communication, one can retrieve data from the watch in simple ASCII-characters, which can be 'translated' into an integer[1].
>> to trigger the data transfer, one has to write a 'V' onto a watch of V1 or '\xC0\x04\x00\xC0' (in HEX) onto a watch of V2. (this happens in communication.py). the string which is returned by the watch has a specific length depending of how many awakemoments one have had.
>> this is also the cause of your bug. the length of the string has not been determined correctly, so there is a loop running behind the length of the string.
>>
>> <<self.awakemoments[1].append(ord(dat[it.next()]))
>> StopIteration>>
>>
>> 'it' is an iterator which is iterated by 'it.next'. dat is the string
>> containing the data. ord converts the ASCII to an integer. 'self' is the
>> object, containing the data. the attribute 'awakemoments' is an 2D-
>> array. the first index are the hours, the second one the minutes, which
>> are referenced by 'awakemoments[0][X]' and 'awakemoments[1][X]'
>> respectively. X starts with length zero, the function 'append' does what
>> it says :D it appends the next hour / minute.
>>
>> to begin to resolve this bug, im interested in what your terminal says. it has to respond with 'Watch uses protocol V1'. if it does not, the string is not filled anyway and cannot be used furtheron, which could cause such an error.
>> we are not that much into exception handling, this is something one has to do in the future, maybe by implementing some kind of easy check. dunno right now.
>>
>> feel free to make some proposals. if you want to read the sourcecode and
>> get stuck at some point, i would pe pleased to help you.
>>
>> best regards,
>> christian.
>>
>> [1]: http://docs.python.org/library/functions.html#ord
>>
>
> --
> You received this bug notification because you are a member of PySleep-
> devs, which is subscribed to PySleep.
> https://bugs.launchpad.net/bugs/839082
>
> Title:
>  Data couldn't be retrieved from Watch
>
> Status in PySleep - Reading & Uploading Data from Sleeptracker Watches:
>  New
>
> Bug description:
>  Traceback (most recent call last):
>    File "src/st_web.py", line 123, in <module>
>      data = watch.getData()
>    File "/home/stefan/PySleep-basic/src/format_data.py", line 143, in getData
>      std.fill(dat)
>    File "/home/stefan/PySleep-basic/src/format_data.py", line 85, in fill
>      self.awakemoments[1].append(ord(dat[it.next()]))
>  StopIteration
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/pysleep/+bug/839082/+subscriptions
>