Detecting USB port connection
up vote
0
down vote
favorite
I am writing a console application in C++. So far my code can detect if my device (linux) has been connected to another device (usually windows) via TCPIP. Once I open Putty on my Windows to connect to my device that is running the console application, my code recognizes it and automatically sends data from my device(linux), to my computer.
I would like to do the same thing with USB. Right now, my console application can send/receive data from my Windows device, BUT only if I send data first. I want my console application to automatically detect if it has been connected to via putty or other application, and automatically start sending data to my microprocessor. I've read and played with libudev by running code that displays when a USB device has been connected and disconnected. I would like to know if there is a way for my device(linux) to know that it has been connected to my PC via Putty, and not a hotplug event. and if so, is there an example floating around somewhere I can use.
would it be a good idea to use sockets? Can I use sockets with usb devices?
Thanks in advanced.
Full disclosure, I am relatively new with Linux OS.
16.04 networking usb putty hotplug
add a comment |
up vote
0
down vote
favorite
I am writing a console application in C++. So far my code can detect if my device (linux) has been connected to another device (usually windows) via TCPIP. Once I open Putty on my Windows to connect to my device that is running the console application, my code recognizes it and automatically sends data from my device(linux), to my computer.
I would like to do the same thing with USB. Right now, my console application can send/receive data from my Windows device, BUT only if I send data first. I want my console application to automatically detect if it has been connected to via putty or other application, and automatically start sending data to my microprocessor. I've read and played with libudev by running code that displays when a USB device has been connected and disconnected. I would like to know if there is a way for my device(linux) to know that it has been connected to my PC via Putty, and not a hotplug event. and if so, is there an example floating around somewhere I can use.
would it be a good idea to use sockets? Can I use sockets with usb devices?
Thanks in advanced.
Full disclosure, I am relatively new with Linux OS.
16.04 networking usb putty hotplug
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am writing a console application in C++. So far my code can detect if my device (linux) has been connected to another device (usually windows) via TCPIP. Once I open Putty on my Windows to connect to my device that is running the console application, my code recognizes it and automatically sends data from my device(linux), to my computer.
I would like to do the same thing with USB. Right now, my console application can send/receive data from my Windows device, BUT only if I send data first. I want my console application to automatically detect if it has been connected to via putty or other application, and automatically start sending data to my microprocessor. I've read and played with libudev by running code that displays when a USB device has been connected and disconnected. I would like to know if there is a way for my device(linux) to know that it has been connected to my PC via Putty, and not a hotplug event. and if so, is there an example floating around somewhere I can use.
would it be a good idea to use sockets? Can I use sockets with usb devices?
Thanks in advanced.
Full disclosure, I am relatively new with Linux OS.
16.04 networking usb putty hotplug
I am writing a console application in C++. So far my code can detect if my device (linux) has been connected to another device (usually windows) via TCPIP. Once I open Putty on my Windows to connect to my device that is running the console application, my code recognizes it and automatically sends data from my device(linux), to my computer.
I would like to do the same thing with USB. Right now, my console application can send/receive data from my Windows device, BUT only if I send data first. I want my console application to automatically detect if it has been connected to via putty or other application, and automatically start sending data to my microprocessor. I've read and played with libudev by running code that displays when a USB device has been connected and disconnected. I would like to know if there is a way for my device(linux) to know that it has been connected to my PC via Putty, and not a hotplug event. and if so, is there an example floating around somewhere I can use.
would it be a good idea to use sockets? Can I use sockets with usb devices?
Thanks in advanced.
Full disclosure, I am relatively new with Linux OS.
16.04 networking usb putty hotplug
16.04 networking usb putty hotplug
edited Nov 12 at 22:02
asked Nov 12 at 19:10
miceandmon
235
235
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Well, there are some major issues with what you are suggesting. A normal USB cable is master->slave, which means that one machine is the controlling machine, and the other is a slave. Both a Windows machine and an Ubuntu machine, would both expect to be the host, controlling the USB operations as the USB-Master. There is nothing off-the-shelf that would change this relationship (but many embedded designs that switch host-slave relationships).
HOWEVER, you can use a USB-Bridge (or Transfer) Cable to communicate over USB between two machines. I found this one on Amazon "Plugable Windows Transfer Cable". You should be able to use this to write a console application on both sides, but would require some experience with Windows and Linux drivers. Not trivial.
I suppose one other idea, would be to use two USB network dongles, and connect them to each other with an ethernet cross-over cable, and setup a local network. You could still use your networking capabilities to communicate between the two devices, but this would be detectable when the USB port is plugged in.
Ethernet cross-over cables and usb networking dongles are readily available, and the drivers well defined (obviously) for Windows and Ubuntu.
New contributor
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Well, there are some major issues with what you are suggesting. A normal USB cable is master->slave, which means that one machine is the controlling machine, and the other is a slave. Both a Windows machine and an Ubuntu machine, would both expect to be the host, controlling the USB operations as the USB-Master. There is nothing off-the-shelf that would change this relationship (but many embedded designs that switch host-slave relationships).
HOWEVER, you can use a USB-Bridge (or Transfer) Cable to communicate over USB between two machines. I found this one on Amazon "Plugable Windows Transfer Cable". You should be able to use this to write a console application on both sides, but would require some experience with Windows and Linux drivers. Not trivial.
I suppose one other idea, would be to use two USB network dongles, and connect them to each other with an ethernet cross-over cable, and setup a local network. You could still use your networking capabilities to communicate between the two devices, but this would be detectable when the USB port is plugged in.
Ethernet cross-over cables and usb networking dongles are readily available, and the drivers well defined (obviously) for Windows and Ubuntu.
New contributor
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
add a comment |
up vote
0
down vote
Well, there are some major issues with what you are suggesting. A normal USB cable is master->slave, which means that one machine is the controlling machine, and the other is a slave. Both a Windows machine and an Ubuntu machine, would both expect to be the host, controlling the USB operations as the USB-Master. There is nothing off-the-shelf that would change this relationship (but many embedded designs that switch host-slave relationships).
HOWEVER, you can use a USB-Bridge (or Transfer) Cable to communicate over USB between two machines. I found this one on Amazon "Plugable Windows Transfer Cable". You should be able to use this to write a console application on both sides, but would require some experience with Windows and Linux drivers. Not trivial.
I suppose one other idea, would be to use two USB network dongles, and connect them to each other with an ethernet cross-over cable, and setup a local network. You could still use your networking capabilities to communicate between the two devices, but this would be detectable when the USB port is plugged in.
Ethernet cross-over cables and usb networking dongles are readily available, and the drivers well defined (obviously) for Windows and Ubuntu.
New contributor
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
add a comment |
up vote
0
down vote
up vote
0
down vote
Well, there are some major issues with what you are suggesting. A normal USB cable is master->slave, which means that one machine is the controlling machine, and the other is a slave. Both a Windows machine and an Ubuntu machine, would both expect to be the host, controlling the USB operations as the USB-Master. There is nothing off-the-shelf that would change this relationship (but many embedded designs that switch host-slave relationships).
HOWEVER, you can use a USB-Bridge (or Transfer) Cable to communicate over USB between two machines. I found this one on Amazon "Plugable Windows Transfer Cable". You should be able to use this to write a console application on both sides, but would require some experience with Windows and Linux drivers. Not trivial.
I suppose one other idea, would be to use two USB network dongles, and connect them to each other with an ethernet cross-over cable, and setup a local network. You could still use your networking capabilities to communicate between the two devices, but this would be detectable when the USB port is plugged in.
Ethernet cross-over cables and usb networking dongles are readily available, and the drivers well defined (obviously) for Windows and Ubuntu.
New contributor
Well, there are some major issues with what you are suggesting. A normal USB cable is master->slave, which means that one machine is the controlling machine, and the other is a slave. Both a Windows machine and an Ubuntu machine, would both expect to be the host, controlling the USB operations as the USB-Master. There is nothing off-the-shelf that would change this relationship (but many embedded designs that switch host-slave relationships).
HOWEVER, you can use a USB-Bridge (or Transfer) Cable to communicate over USB between two machines. I found this one on Amazon "Plugable Windows Transfer Cable". You should be able to use this to write a console application on both sides, but would require some experience with Windows and Linux drivers. Not trivial.
I suppose one other idea, would be to use two USB network dongles, and connect them to each other with an ethernet cross-over cable, and setup a local network. You could still use your networking capabilities to communicate between the two devices, but this would be detectable when the USB port is plugged in.
Ethernet cross-over cables and usb networking dongles are readily available, and the drivers well defined (obviously) for Windows and Ubuntu.
New contributor
New contributor
answered Nov 12 at 19:33
Keitai Otaku
463
463
New contributor
New contributor
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
add a comment |
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
Sorry.I didn't explain well.My linux device is a microprocessor (Boundary Device)and has the micro USB connector on it.That device is then plugged into my PC. So the microprocessor is running the console application, but it waits for commands from my PC.When I connect using TCP/IP, it works great.I want this same feature with my USB.Right now, I can connect via USB, but it does not connect until I type something into my Putty console of my Windows device.I want my console application to detect if it has been connected to, and then send data first,instead of waiting until it has received data
– miceandmon
Nov 12 at 21:03
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1092313%2fdetecting-usb-port-connection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown