Activating USB port via an AppleScript programs

I must leave a video camera connected with a USB port to my MacBook in all time.

However, at several occasions during the day I must activate the connection between the camera and the MacBook. At the moment I perform this operation by unplugging and plugging the USB cable to the MacBook.

When plugging the USB cable to the MacBook a message appears on the LCD screen of the camera asking which disk I wanted to connect on the camera. I select A or B and then I am able to see all video clips I’ve created on A or B.

Once I am ready to continue filming I perform an Eject from the MacBook and I am then ready to continue filming.

At this moment I would like to create an AppleScript which would be performing the connection without me having to plug and unplug the USB cable?

Is this possible?

THANKS in advance!

Daniel

Browser: Safari 533.16
Operating System: Mac OS X (10.6)

It might work similarly to remounting a drive, I don’t have a camera to test it with but this could work:


set MP to do shell script "/usr/sbin/diskutil list | /usr/bin/awk '/" & NameOfCamera & "/ {print $NF}'"
do shell script "/usr/sbin/diskutil mount " & MP

I got this from somewhere else in the forum a while ago, for mounting drives. Just use the name your camera mounts with as NameOfCamera.

Hi,

as far as I know it’s not possible, because the system doesn’t recognize USB devices when they are connected but not mounted.

Thanks for the information.

When I connect the USB cable to the MacBook and look a the finder the name of the SDHC card appears. At the moment the disk is call PZV04.

I see the disk PZV04 right under the Macintosh HD

I can then go through the directory of PZV04 and rename files as I want.

The name of the camera is not visible but the name of SDHC card I want to manipulate does appear.

I’ve tried what visciousfishes3000 has recommended where NX5U is the name of my camera.

I’ve got the following error message

When I connect the USB cable to the computer the message " USB select" appear on the camera LCD monitor. I then select the card I want my MacBook to point at and on the LCD monitor screen it says “Connected. Do not unplug the USB cable. Do not turn off the power”. Right from there I have access to the content of the SDHC card found in my camera.

If I remove the cable of the MacBook (no performing an eject" I get the dialog box saying the “disk was not removed correctly…”

What I want to eliminate here is the action of manually having to insert and remove the USB cable from my computer. In doing so I would then selecting through the camera LCD monitor the wanted SDHC card.

Since I will be connecting/removing more 60 times a day I would like to know how it can be done from a program. This to reduce the risk of damaging the MackBook USB port entry.

Best regards!
Daniel

Hello

Trying doesn’t hurt. -I think Stefan is right anyway, but lets have a go :slight_smile:

You must use the exactly the same script as the one visciousfishes3000 posted - It seems to me that you have some
errors in the snippet.

Try opening the snippet directly into the script editor, then use this as the first line in that script to provide the cameraname.


set NameOfCamera to "NXU5"

Then enter these two lines as an intermediary step below the set MP to do shell script “/usr/sbin/diskutil list | /usr/bin/awk '/” & NameOfCamera & “/ {print $NF}'” line.

display dialog MP
return

If you get any results here, (anything but a blank dialog box), then you can comment out these two lines
and try to run the script again.( “”” (2 hyphens) in front of a line is what makes a line a comment ) Then it may actually happen that you can mount the drive.

Best Regards

McUsr

MANY thanks for trying to help me!

I’ve tried the script as suggested and I had a blank dialog box.

I then got the following error message

The camera itself does not have a name.

There are two SDHC card in the camera, one of them named NX5U. Its only when I plug the USB cable onto the MacBook or onto the camera that I am given the option, on the camera LCD monitor, to choose between A and B. A being the SDHC card called NX5U and the other being the memory stick pro-HG Duo that I named S-NX5U (S for Sony).

Right then in the Finder the NX5U disk or S-NX5U disks appears.

To enable this behavior, I physically unplugged and plugged the USB cable on either the camera or the MacBook.

P.S. In being able to trigger this action, the other script http://macscripter.net/viewtopic.php?id=33297 will then get automatically executed.


set NameOfCamera to "NXU5"
set MP to do shell script "/usr/sbin/diskutil list | /usr/bin/awk '/" & NameOfCamera & "/ {print $NF}'"
display dialog MP
do shell script "/usr/sbin/diskutil mount " & MP

Regards!
Daniel

I’d like to repeat:

IT IS NOT POSSIBLE

Two reasons:

¢ USB devices like flash drives including memory cards are not listed using diskutil list while they are connected but not mounted, therefore you can’t mount them because you can’t gather the BSD name.

¢ If the camera controls the decision which memory device is connected thru its USB port, you can’t control it from outside

It’s similar to the TomTom navigation devices. When you plug in the device into an USB port, you have to confirm a “Connect to Computer” message on the touch screen of the navigation device. If you deny, nothing will be mounted

Thanks Stefan for the information.

I will have to unplug and replug the USB cable closed to 40 times a day onto two MackBook. There is a high potential for me to break the USB port and this is what I want to avoid. Two Mackbook and the camera itself

What appends on the system with I plug and unplug a USB cable. There is some electrical/electronical system behavior which says someone is trying to connect to your hardware.

If I read your comment correctly, there is no way to spark this type of electrical/electronical without physically unplugging and plugiing the cable.

This is really unfortunate.

I will have to see what I can do for not burning the USB port. I had to go through this type of problem once.

Best regards!
Daniel

Exactly