X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tools%2Fplatforms%2Fmsp430%2Fmotelist%2Fmotelist-win32.cpp;h=803d97d9e0a56e534b1af63293245a15e2d3c218;hp=8abbf087da9be5626522af6b4bad4f79917ea53a;hb=da0fc4a07b170b5c2c4b1ead622701be794a4de6;hpb=5312c1ac9464a4c368f38efeb9f46dc474066d09 diff --git a/tools/platforms/msp430/motelist/motelist-win32.cpp b/tools/platforms/msp430/motelist/motelist-win32.cpp index 8abbf087..803d97d9 100644 --- a/tools/platforms/msp430/motelist/motelist-win32.cpp +++ b/tools/platforms/msp430/motelist/motelist-win32.cpp @@ -22,6 +22,9 @@ // @author Cory Sharp +// Support for CP2103 by Sporian Microsystems, Inc. and R. Steve McKown +// + #include #include #include @@ -86,7 +89,7 @@ struct RegValue case REG_DWORD: data_int = *(DWORD*)_data; - nbuf = sprintf( buf, "%d", *(DWORD*)_data ); + nbuf = sprintf( buf, "%lu", *(DWORD*)_data ); data = String( buf, buf+nbuf ); break; @@ -319,10 +322,8 @@ int getRefCount( const RegKey& dclass, const RegKey& key ) return refcnt; } -ListDevice getDevices() +void getFTDIDevices(ListDevice& devs) { - ListDevice devs; - String ccs = "SYSTEM\\CurrentControlSet\\"; RegKey dclass( HKEY_LOCAL_MACHINE, ccs+"Control\\DeviceClasses" ); RegKey ftdibus( HKEY_LOCAL_MACHINE, ccs+"Enum\\FTDIBUS" ); @@ -360,6 +361,55 @@ ListDevice getDevices() devs.push_back(d); } } +} + +void getCP210xDevices(ListDevice& devs) +{ + String ccs = "SYSTEM\\CurrentControlSet\\"; + String enums = "Enum\\USB\\Vid_10c4&Pid_ea60"; + RegKey dclass(HKEY_LOCAL_MACHINE, ccs+"Control\\DeviceClasses"); + RegKey usb10c4(HKEY_LOCAL_MACHINE, ccs+enums); + RegKey usb10c4tty(HKEY_LOCAL_MACHINE, ccs+enums+"&Mi_00"); + + VecString cdev = usb10c4.getSubkeyNames(); + for( VecString::const_iterator i=cdev.begin(); i!=cdev.end(); i++ ) + { + Device d; + d.id = i->substr(0, 8); + + try + { + RegKey devkey = usb10c4tty[*i+"_00"]; + d.comm = devkey["Device Parameters"]("PortName").data; + } + catch( std::runtime_error e ) + { + d.comm = "no_comm"; + } + + try { d.info = usb10c4[*i]("LocationInformation").data; } + catch( std::runtime_error e ) { } + + try { + d.refcount = getRefCount( dclass, usb10c4[*i] ); + } + catch( std::runtime_error e ) { } + + String::size_type ncomm = d.comm.find_first_of("0123456789"); + if( ncomm != String::npos ) + d.sortnum = atoi( d.comm.substr(ncomm).c_str() ); + + devs.push_back(d); + } +} + + +ListDevice getDevices() +{ + ListDevice devs; + + getFTDIDevices(devs); + getCP210xDevices(devs); return devs; }