Population of a PullDownMenu with USB Port Names
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 30
- Joined: Sun Feb 28, 2010 9:52 pm
- Location: Miami, Florida
- Contact:
Population of a PullDownMenu with USB Port Names
After two hours of googlin' and searching the runrev sites, I've been unable to find an example of how to populate a pull down menu with available USB/Serial Ports. How do we get a hardware list of ports to populate such a list? (Mostly for the Mac)
Hard coded list:
/dev/cu.usbserial-A9006LdD
/dev/cu.Bluetooth-PDA-Sync
/dev/cu.ARDUINOBT-BluetoothSeri-1
-
/dev/cu.modem
However I need one with devices currently plugged in.
Thanks
~David
Hard coded list:
/dev/cu.usbserial-A9006LdD
/dev/cu.Bluetooth-PDA-Sync
/dev/cu.ARDUINOBT-BluetoothSeri-1
-
/dev/cu.modem
However I need one with devices currently plugged in.
Thanks
~David
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Population of a PullDownMenu with USB Port Names
David,
does this help?
http://n4.nabble.com/list-of-USB-driver ... ml#a332688
especially
http://pdslabs.net/stacks/libUsbDrive.rev.zip
by Phil Davis
I don't know anything about USB.
regards
Bernd
does this help?
http://n4.nabble.com/list-of-USB-driver ... ml#a332688
especially
http://pdslabs.net/stacks/libUsbDrive.rev.zip
by Phil Davis
I don't know anything about USB.
regards
Bernd
Re: Population of a PullDownMenu with USB Port Names
Hello David,
On Mac you can use with advantage the BSD commands.
Under Revo, these commands are accessible via the function : shell ()
Here is a script which allows to get back the list of the active ports such as it appears in " informations system ".
The ideal being to launch the script at the opening of the stack.
[/size]
The last part of this code just extract the type of the existing ports and bring it to a button with pull down menu. But a lot of other informations are accessible via the "system_profiler" command. By exemple, with the "SPUSBDataType" argument :
USB Bus:
Vendor Name: Apple Computer, Inc.
Product ID: 32773 ($8005)
Speed: Up to 12 Mb/sec
Bus Power (mA): 500
U3 Smart Drive:
Capacity: 974.5 MB
Drive Type: CD-ROM
Removable Media: Yes
Detachable Drive: Yes
BSD Name: disk3
OS9 Drivers: No
Product ID: 7760 ($1e50)
Speed: Up to 12 Mb/sec
Vendor Name: EMTEC
Bus Power (mA): 500
Serial Number: 070007771FB00018
With the hope it will help you.
regards,
renaud
On Mac you can use with advantage the BSD commands.
Under Revo, these commands are accessible via the function : shell ()
Here is a script which allows to get back the list of the active ports such as it appears in " informations system ".
The ideal being to launch the script at the opening of the stack.
Code: Select all
on openstack
set cursor to busy
put "put return & shell (" & quote & "system_profiler SPNetworkDataType" & quote & ") after resum" into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPIDEDataType" & quote & ") after resum" into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPSCSIDataType" & quote & ") after resum" into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPUSBDataType" & quote & ") after resum" & quote into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPFireWireDataType" & quote & ") after resum" into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPAirPortDataType" & quote & ") after resum" into lacomm
do lacomm
put "put return & shell (" & quote & "system_profiler SPModemDataType" & quote & ") after resum" into lacomm
do lacomm
sort resum
repeat with i = the number of lines in resum down to 1
if char 1 of line i of resum is not " " then next repeat
if char 1 to 5 of line i of resum = " " then
exit repeat
else
if "Hardware" is in line i of resum then
next repeat
end if
if "modem" is in line i of resum then
put word 1 of line i of resum after portList
put return after last char of portList
next repeat
end if
delete char 1 to 4 of line i of resum
put line i of resum after portList
put return into last char of portList
end if
end repeat
delete last char of portList
put "Choose a port" & return & "-" & return & portList into btn "ThePorts"
end openstack
The last part of this code just extract the type of the existing ports and bring it to a button with pull down menu. But a lot of other informations are accessible via the "system_profiler" command. By exemple, with the "SPUSBDataType" argument :
USB Bus:
Vendor Name: Apple Computer, Inc.
Product ID: 32773 ($8005)
Speed: Up to 12 Mb/sec
Bus Power (mA): 500
U3 Smart Drive:
Capacity: 974.5 MB
Drive Type: CD-ROM
Removable Media: Yes
Detachable Drive: Yes
BSD Name: disk3
OS9 Drivers: No
Product ID: 7760 ($1e50)
Speed: Up to 12 Mb/sec
Vendor Name: EMTEC
Bus Power (mA): 500
Serial Number: 070007771FB00018
With the hope it will help you.
regards,
renaud
-
- Posts: 33
- Joined: Tue Apr 25, 2017 8:13 pm
Re: Population of a PullDownMenu with USB Port Names
Hi!
Reviving this thread
I'm having trouble trying to figure out how to make this pull down menu not with the USB port names but with the "BSD Device Name". This way it would be easier to select the right port to connect with an arduino for example.
Any suggestions?
Thanks!
Reviving this thread
I'm having trouble trying to figure out how to make this pull down menu not with the USB port names but with the "BSD Device Name". This way it would be easier to select the right port to connect with an arduino for example.
Any suggestions?
Thanks!
NoN' wrote:Hello David,
On Mac you can use with advantage the BSD commands.
Under Revo, these commands are accessible via the function : shell ()
Here is a script which allows to get back the list of the active ports such as it appears in " informations system ".
The ideal being to launch the script at the opening of the stack.
[/size]Code: Select all
on openstack set cursor to busy put "put return & shell (" & quote & "system_profiler SPNetworkDataType" & quote & ") after resum" into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPIDEDataType" & quote & ") after resum" into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPSCSIDataType" & quote & ") after resum" into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPUSBDataType" & quote & ") after resum" & quote into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPFireWireDataType" & quote & ") after resum" into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPAirPortDataType" & quote & ") after resum" into lacomm do lacomm put "put return & shell (" & quote & "system_profiler SPModemDataType" & quote & ") after resum" into lacomm do lacomm sort resum repeat with i = the number of lines in resum down to 1 if char 1 of line i of resum is not " " then next repeat if char 1 to 5 of line i of resum = " " then exit repeat else if "Hardware" is in line i of resum then next repeat end if if "modem" is in line i of resum then put word 1 of line i of resum after portList put return after last char of portList next repeat end if delete char 1 to 4 of line i of resum put line i of resum after portList put return into last char of portList end if end repeat delete last char of portList put "Choose a port" & return & "-" & return & portList into btn "ThePorts" end openstack
The last part of this code just extract the type of the existing ports and bring it to a button with pull down menu. But a lot of other informations are accessible via the "system_profiler" command. By exemple, with the "SPUSBDataType" argument :
USB Bus:
Vendor Name: Apple Computer, Inc.
Product ID: 32773 ($8005)
Speed: Up to 12 Mb/sec
Bus Power (mA): 500
U3 Smart Drive:
Capacity: 974.5 MB
Drive Type: CD-ROM
Removable Media: Yes
Detachable Drive: Yes
BSD Name: disk3
OS9 Drivers: No
Product ID: 7760 ($1e50)
Speed: Up to 12 Mb/sec
Vendor Name: EMTEC
Bus Power (mA): 500
Serial Number: 070007771FB00018
With the hope it will help you.
regards,
renaud
Re: Population of a PullDownMenu with USB Port Names
Hi Vasco,
After seven years of reflection, I can tell you that the solution was already in my precedent post...
Try that :
Hope it will help
regards,
renaud
After seven years of reflection, I can tell you that the solution was already in my precedent post...
Try that :
Code: Select all
on mouseUp
set cursor to busy
put "put shell (" & quote & "system_profiler SPUSBDataType" & quote & ") into resum" into lacomm
do lacomm
set itemdelimiter to ":"
repeat with i = 1 to the number of lines in resum
if line i of resum contains "BSD name" then
put last item of line i of resum & return after ron2
end if
end repeat
delete last char of ron2
put "Choose a port" & return & "-" & return & ron2 into btn "ThePorts"
end mouseup
regards,
renaud
-
- Posts: 33
- Joined: Tue Apr 25, 2017 8:13 pm
Re: Population of a PullDownMenu with USB Port Names
It really was but I'm quite dumb, I'm sorry... And thank you for your help!
In fact, I'm not a programmer and I still have some doubts of how this code works, but I do know enough to "tinker" pieces of code. For example what you gave me didn't work at first, but I was ready for this possibility. It works if I do this changes:
and
It shows a little more stuff than I wanted but the name is there, so I have now a way to work it out.
Thank you so much!
In fact, I'm not a programmer and I still have some doubts of how this code works, but I do know enough to "tinker" pieces of code. For example what you gave me didn't work at first, but I was ready for this possibility. It works if I do this changes:
Code: Select all
put "put shell (" & quote & "system_profiler SPNetworkDataType" & quote & ") into resum" into lacomm
do lacomm
Code: Select all
if line i of resum contains "BSD Device Name" then
put last item of line i of resum & return after ron2
end if
It shows a little more stuff than I wanted but the name is there, so I have now a way to work it out.
Thank you so much!
NoN' wrote:Hi Vasco,
After seven years of reflection, I can tell you that the solution was already in my precedent post...
Try that :
Hope it will helpCode: Select all
on mouseUp set cursor to busy put "put shell (" & quote & "system_profiler SPUSBDataType" & quote & ") into resum" into lacomm do lacomm set itemdelimiter to ":" repeat with i = 1 to the number of lines in resum if line i of resum contains "BSD name" then put last item of line i of resum & return after ron2 end if end repeat delete last char of ron2 put "Choose a port" & return & "-" & return & ron2 into btn "ThePorts" end mouseup
regards,
renaud
Re: Population of a PullDownMenu with USB Port Names
Don't be sorry and bravo, it's a beautiful transformation for a "non programmer"!
Have a good day.
renaud
Have a good day.
renaud
Re: Population of a PullDownMenu with USB Port Names
Hi friends,
why not just:
?
Best
Klaus
why not just:
Code: Select all
...
## put "put shell (" & quote & "system_profiler SPUSBDataType" & quote & ") into resum" into lacomm
## do lacomm
put shell ("system_profiler SPUSBDataType") into resum
...
Best
Klaus
-
- Posts: 33
- Joined: Tue Apr 25, 2017 8:13 pm
Re: Population of a PullDownMenu with USB Port Names
Thank you Renaud! Using your code I got to another way of doing what I wanted again, I think it is a simpler way, so I'll leave here... It can be useful for other noobs like me!NoN' wrote:Don't be sorry and bravo, it's a beautiful transformation for a "non programmer"!
Have a good day.
renaud
Code: Select all
set cursor to busy
put shell ("ls /dev/cu.*") into resum
put "Choose a port" & return & "-" & return & resum into btn "ThePorts"
Vasco
EDIT
Thank you Klaus, I think my tinker spirit got me to a similar conclusion.Klaus wrote:Hi friends,
why not just:?Code: Select all
... ## put "put shell (" & quote & "system_profiler SPUSBDataType" & quote & ") into resum" into lacomm ## do lacomm put shell ("system_profiler SPUSBDataType") into resum ...
Best
Klaus
Best regards,
Vasco
Re: Population of a PullDownMenu with USB Port Names
Hi Klaus,
Because of the beauty of course
No, you are absolutly right I don't remember the reason why I used this structure in my initial post seven years ago, but there is no reason here.
Thank you for this simplification.
Best
Renaud
Because of the beauty of course
No, you are absolutly right I don't remember the reason why I used this structure in my initial post seven years ago, but there is no reason here.
Thank you for this simplification.
Best
Renaud