Changeset 598

Show
Ignore:
Timestamp:
06/05/09 14:09:02 (4 years ago)
Author:
balle
Message:

- fix btconnect (handle already used devices better, fix awk script and regexes)
- fix path in transfermotorcontroltonxt.sh

Location:
branches/livecd/LiveTools
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/livecd/LiveTools/btconnect

    r597 r598  
    3535fi 
    3636 
     37# if device name is given, check if it's already used 
     38 
     39if [ $# = 2 ]; then 
     40        (( DEVICE=$2 )) 
     41        if [ -e /dev/rfcomm$DEVICE -o -e /dev/bluetooth/rfcomm$DEVICE ]; then 
     42                echo "rfcomm$DEVICE is already in use!" 
     43                exit 3 
     44        fi 
     45fi 
     46 
    3747# if hardware address is given, we're all set. otherwise, perform a scan 
    3848 
    39 if [[ $1 =~ '^([[:digit:]a-fA-F]{2}:){5}[[:digit:]a-fA-F]{2}$' ]]; then 
     49if [[ $1 =~ ^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$ ]]; then 
    4050        MAC=$1 
    4151else 
    42         $NAME="$( echo $1 )" 
     52        NAME=$1 
    4353        echo -n "Scanning for '$NAME' ... " >&2 
    44         MAC=$( hcitool scan | awk -F '[[:space:]]+' '$2 ~ /([[:digit:]a-fA-F]{2}:){5}[[:digit:]a-fA-F]{2}/ && $3 == "'"$NAME"'" && $NF == 3 / { print( $2 ) }' ) 
     54        MAC=$( hcitool scan | awk '$1 ~ /^([0-9a-fA-F]+:)+[0-9a-fA-F]+$/ && $2 == "'"$NAME"'" { print $1 }' ) 
    4555        if [ -z $MAC ]; then 
    4656                echo "not found." >&2 
    4757                exit 1 
    4858        fi 
    49         if [[ $MAC =~ ' ' ]]; then 
     59        if [[ $MAC == *\ * ]]; then 
    5060                echo "found multiple devices:" >&2 
    5161                echo >&2 
     
    6070fi 
    6171 
    62 if [ $# = 2 ]; then 
    63         DEVICE=$(( $2 )) 
    64 else 
    65         DEVICE=0 
    66         INUSE=$( rfcomm | cut -f 1 ) 
    67         while [[ $INUSE =~ "rfcomm$DEVICE:" ]]; do 
     72# if device is not given, find first unused device 
     73 
     74if [ -z $DEVICE ]; then 
     75        (( DEVICE=0 )) 
     76        while [ -e /dev/rfcomm$DEVICE -o -e /dev/bluetooth/rfcomm$DEVICE ]; do 
    6877                (( DEVICE++ )) 
    6978        done 
  • branches/livecd/LiveTools/transfermotorcontroltonxt.sh

    r597 r598  
    1111read 
    1212 
    13 nbc -d -S=usb /opt/mindstorms/matlab/MotorControl/MotorControl.nxc 
     13nbc -d -S=usb /opt/mindstorms/MotorControl/MotorControl.nxc