Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

This page details some Linux / Windows / MacOS tricks we find very useful.

...

Python

Expand
titleOpen a serial port in Python, without knowing its number.

When you plug a mote in your Linux-based OpenLBR, it will appear as /dev/ttyUSBx, where x is a number. Similarly, when plugged into Windows, it appears as COMx in your device manager. It is frustrating, each time you plug in a mote, to look for that number and change a global variable in your Python script.

Instead, the following script scans for the connected motes and returns a list containing the list of the serial ports a mote is connected to.

Code Block
languagepython
#!python
import os

serialport_names = []

def findSerialPortsNames():
   global serialport_names
   if os.name=='nt':
      path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
      key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
      for i in range(winreg.QueryInfoKey(key)[1]):
         try:
            val = winreg.EnumValue(key,i)
         except:
            pass
         else:
            if val[0].find('VCP') > -1:
               serialport_names.append(str(val[1]))
      serialport_names.sort()
   elif os.name=='posix':
      serialport_names = glob.glob('/dev/ttyUSB*')
      serialport_names.sort()

After running the findSerialPortsNames() function, you script can open the first serial port using:

Code Block
languagepython
serialHandler = serial.Serial(serialport_names[0],baudrate=115200)

...

Expand
titleConnect a TelosB to a MAC OSX computer.

Install Xcode from Mac OS X install DVD. This adds developer support applications. You must check Unix development tools or something like that during the install to get unix support for the typical gcc, perl, etc. Python 2.5.4 is run by typing python2.5 at the terminal. NOTE: this may change with future releases of Apple xcode.

Install pyserial from http://pyserial.sourceforge.net/

Install virtual com port driver from http://www.ftdichip.com/Drivers/VCP.htm for MAC OSX.

A Crossbow TelosB mote shows up as something like /dev/tty.usbserial-XBRAHH4P.

 

...

.

Git and GitHub

Expand
titleDelete a branch using TortoiseSVN.
Warning

You will be removing the branch directly on GitHub. If you have not merged it back into another branch, the changes in the branch you delete will be lost.

  1. Hold Shift and right-click on your source code directory. Choose TortoiseGit, Browse Reference.
  2. On the left, expand remotes and select origin.
  3. Right-click on the branch you want to delete and select Delete remote branch.
  4. Accept the warnings if you know what you're doing.