Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
1,598 Views

Detect if USB cable is connected to ttyGS0?

Jump to solution

Hi!

I'm intending to run an application on the edison which gets user input of a textfile which lies on the mass storage

partition that shows up when e.g. a windows machine is connected. The intention is that everybody can edit this file

easily and after plugging of the USB cable and rebooting the edison a c++ app mounts the partition, reads out the

textfile and uses the infos out of it. The c++ app is started automatically when the edison boots and mounts the partition.

The problem is that when the partition is mounted with

losetup -o 8192 /dev/loop0 /dev/disk/by-partlabel/update

mount /dev/loop0 /update

... the USB port disconnects and thus the user on the windows machine can't edit anything anymore. How can

I detect programmatically (or over any shell command) that the ttyGS0 port is used?

the optimum would be to recognise the USB connection in a loop and wait for it's disconnection.

Thanks!


Accepted Solutions
Highlighted
Employee
38 Views

Hello Christoph.P,

I believe the script found in https://github.com/MakersTeam/Edison/blob/master/Python-Examples/USB/USBCheckStatus.py Edison/USBCheckStatus.py at master · MakersTeam/Edison · GitHub might be just what you were looking for. There is still some optimizations needed to be done, but you can base your project on this script.

Peter.

View solution in original post

0 Kudos
4 Replies
Highlighted
Employee
39 Views

Hello Christoph.P,

I believe the script found in https://github.com/MakersTeam/Edison/blob/master/Python-Examples/USB/USBCheckStatus.py Edison/USBCheckStatus.py at master · MakersTeam/Edison · GitHub might be just what you were looking for. There is still some optimizations needed to be done, but you can base your project on this script.

Peter.

View solution in original post

0 Kudos
Highlighted
New Contributor I
38 Views

Generally, I don't think it is a good idea to have two host trying to be the master of the same device at the same time. This may be why windows disconnects. I can do this with a linux host, double mounting, but there seems to be an inconsistency with the contents of the file.

jeff

Highlighted
New Contributor II
38 Views

Thank you very much!

That was indeed I was looking for!

Highlighted
Employee
38 Views

I'm glad to hear that, it's great to be of help. If you ever encounter any other issue, don't hesitate to come back to the community.

Peter.

0 Kudos