pebble / libpebble2

The library portion of the successor to libpebble
MIT License
64 stars 29 forks source link

Seria Transport freezes infinitly on windows 10 #18

Open grodino opened 8 years ago

grodino commented 8 years ago

Hi pebblers,

I'm currently trying to get libpebble2 running on windows 10. I'm using the serial transport to communicate with my watch. When I call pebble.run_async() the code doesn't do anything and never stop, without displaying anything.

I first thought that the problem was coming from python 3.5 but I tried it too on python 2.7 and it didn't work.

I am on windows 10 and here is my code :

import logging
import serial

from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.serial import SerialTransport

from libpebble2.protocol import *
from libpebble2.services.notifications import Notifications
from libpebble2.services.screenshot import Screenshot

logging.basicConfig(level=logging.DEBUG)

pebble = PebbleConnection(
    SerialTransport('COM3'),
    log_protocol_level=logging.DEBUG,
    log_packet_level=logging.DEBUG
    )

pebble.connect()
pebble.run_async()

Thank you for your help !

iksaku commented 8 years ago

It is not freezed, it is waiting for you to send instructions. Try sending a Ping message as described in the Docs

grodino commented 8 years ago

Thank you for your answer, In deed I tried to do it several times and it did not do anything. The only result I get when I set debug level to DEBUG is this :

DEBUG:libpebble2.communication:-> WatchVersion(command=None, data=WatchVersionRequest())
DEBUG:libpebble2.communication:-> 0001001000

And here is the code :

import logging
import serial

from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.serial import SerialTransport

from libpebble2.protocol import *

logging.basicConfig(level=logging.DEBUG)

pebble = PebbleConnection(
    SerialTransport('COM10'),
    log_protocol_level=logging.DEBUG,
    log_packet_level=logging.DEBUG
    )
pebble.connect()
pebble.run_async()

print(pebble.watch_info.serial)

pebble.send_packet(PingPong(message=Ping(), cookie=53))
pebble.read_from_endpoint(PingPong)

print(pebble.watch_info.serial)
iksaku commented 8 years ago

Why don't you try print results from endpoint reading? You are just printing watch_info property

grodino commented 8 years ago

Yes, I tried it but it is breaking before this.

Actually, the freeze occurs when the SerialTransport calls serial.write() when trying to fetch Watchversion

I've heard about Windows 10 problems with bluetooth COM ports, it might be something like that.

iksaku commented 8 years ago

Could you provide some "breaking" code?

grodino commented 8 years ago

I'm sorry I don't understand what you mean by "breaking code" ?

iksaku commented 8 years ago

Can you post code that actually "doesn't work"

grodino commented 8 years ago

Oh ok thank you for the explenation, The breaking code is the few lines I posted before :

import logging
import serial

from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.serial import SerialTransport

from libpebble2.protocol import *

logging.basicConfig(level=logging.DEBUG)

pebble = PebbleConnection(
    SerialTransport('COM10'),
    log_protocol_level=logging.DEBUG,
    log_packet_level=logging.DEBUG
    )
pebble.connect()
pebble.run_async() # The code freezes here

print(pebble.watch_info.serial)

pebble.send_packet(PingPong(message=Ping(), cookie=53))
pebble.read_from_endpoint(PingPong)

print(pebble.watch_info.serial)