import sys
import time

from ant.core import driver
from ant.core import message
from ant.core.constants import *

from config import *

# Initialize
stick = driver.USB1Driver(SERIAL, log=LOG, debug=DEBUG)
stick.open()

# Prepare system reset message
msg = message.Message()
msg.setType(MESSAGE_SYSTEM_RESET)
msg.setPayload('\x00')

# Send
stick.write(msg.encode())

# Wait for reset to complete
time.sleep(1)

# Alternatively, we could have done this:
msg = message.SystemResetMessage()
stick.write(msg.encode())
time.sleep(1)

# Shutdown
예제 #2
0
from ant.core.constants import *

from config import *

# Initialize
stick = driver.USB1Driver(SERIAL, log=LOG, debug=DEBUG)
stick.open()

# Reset stick
msg = message.SystemResetMessage()
stick.write(msg.encode())
time.sleep(1)

# Request stick capabilities
msg = message.ChannelRequestMessage()
msg.setMessageID(MESSAGE_CAPABILITIES)
stick.write(msg.encode())

# Read response
hdlfinder = message.Message()
capmsg = hdlfinder.get_handler(stick.read(8))

print 'Std Options:', capmsg.getStdOptions()
print 'Adv Options:', capmsg.getAdvOptions()
print 'Adv Options 2:', capmsg.getAdvOptions2()
print 'Max Channels:', capmsg.getMaxChannels()
print 'Max Networks:', capmsg.getMaxNetworks()

# Shutdown
stick.close()