X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tools%2Fplatforms%2Fmsp430%2Fpybsl%2Ftos-bsl.in;h=6809e3b6184d6e97a0df24f88b973f02dd41d871;hp=4cd94d86da85ea28b840d70d83279301ba56e1c0;hb=add98f2f5788d2ee9f8104881fd0a2bc97f2c209;hpb=4b943ec81ebdc1582de77b529dbec1419e611af5 diff --git a/tools/platforms/msp430/pybsl/tos-bsl.in b/tools/platforms/msp430/pybsl/tos-bsl.in old mode 100644 new mode 100755 index 4cd94d86..6809e3b6 --- a/tools/platforms/msp430/pybsl/tos-bsl.in +++ b/tools/platforms/msp430/pybsl/tos-bsl.in @@ -116,7 +116,7 @@ # from bsl_standard or one of its specializations. # -import sys, fcntl, time, string, cStringIO, struct +import sys, time, string, cStringIO, struct sys.path.append("@tinyoslibdir@") import serial @@ -1423,6 +1423,12 @@ class bsl_cp2103(bsl_standard): bsl_standard.bslInit(self) +if sys.platform == 'win32': + sys.path.append('.') + import cp210xrt +else: + import fcntl + GPIOBIC = 0x89f2 GPIOBIS = 0x89f3 GPIO_2 = 0x04 @@ -1439,7 +1445,7 @@ class cp2103_posix: def setGpio2(self, assertme): """ set not assertme to the gpio pin """ - if not self.fd: raise "connection not open" + if not self.fd: raise BSLException("connection not open") if assertme: fcntl.ioctl(self.fd, GPIOBIC, GPIO_2) else: @@ -1448,7 +1454,7 @@ class cp2103_posix: def setGpio3(self, assertme): """ set not assertme to the gpio pin """ - if not self.fd: raise "connection not open" + if not self.fd: raise BSLException("connection not open") if assertme: fcntl.ioctl(self.fd, GPIOBIC, GPIO_3) else: @@ -1456,42 +1462,36 @@ class cp2103_posix: time.sleep(0.010) # no sleep = too fast -class cp2103_cygwin: +class cp2103_win32: """ - Implements cp2103 gpio access for windows cygwin systems via the + Implements cp2103 gpio access for windows win32 systems via the cp210x VCP and the CP210xRuntime.dll. """ def __init__(self, serialport): - import cp210xrt - sys.stderr.write("cp2103_cygwin\n") - self.fd = serialport.fd + self.hComPort = serialport.hComPort def setGpio2(self, assertme): """ set not assertme to the gpio pin """ - import cp210xrt if assertme: - cp210xrt.writeLatch(self.fd, GPIO_2, 0) + cp210xrt.writeLatch(self.hComPort, GPIO_2, 0) else: - cp210xrt.writeLatch(self.fd, GPIO_2, GPIO_2) + cp210xrt.writeLatch(self.hComPort, GPIO_2, GPIO_2) def setGpio3(self, assertme): """ set not assertme to the gpio pin """ - import cp210xrt if assertme: - cp210xrt.writeLatch(self.fd, GPIO_3, 0) + cp210xrt.writeLatch(self.hComPort, GPIO_3, 0) else: - cp210xrt.writeLatch(self.fd, GPIO_3, GPIO_3) + cp210xrt.writeLatch(self.hComPort, GPIO_3, GPIO_3) def cp2103_factory(serialport): - import os; - if os.name == 'posix': - if sys.platform == 'cygwin': - return cp2103_cygwin(serialport) - else: - return cp2103_posix(serialport) + if sys.platform == 'win32': + return cp2103_win32(serialport) + elif sys.platform != 'cygwin': + return cp2103_posix(serialport) else: - raise "No cp2103 support is available for your platform." + raise BSLException("No cp2103 support is available for your platform.") def getClass(classname, modulename="__main__"):