USB port number - embedded

I have a device that I need to program from my computer. It uses a serial to usb cable to communicate with my computer. When programming the device I have to provide the port number, ttyUSBn. How do I know the number of the USB port I'm using?

On a MAC/OSX you can use the following in a terminal window: ls /dev/tty.*

Related

Assign and Pin USB device to COM port

Much like DHCP and LAN IP addresses, I would like to configure a Win10 laptop to reserve and assign a USB device to COM15. If you have successfully done this before, please state this in your response and any lessons learned. I look forward to any references / examples. Thank you
If your device reports a USB serial number in its descriptors, then Windows will remember the device and always assign it to the same COM port number. You can change the COM port by going to the Device Manager (devmgmt.msc), double-clicking on the COM port, going to the "Port Settings" tab, and clicking "Advanced...".
If your device does not have a serial number in its descriptors, then you need to repeat the procedure above for every USB port on your computer that you might want to plug the device into. The reason for this is that the device's Device Instance Id, instead of including the serial number, will have some sort of string with ampersands in it that depends on what port the device is plugged into. This ID is what gets associated with a COM port, so you need to make sure all of the possible IDs of the device are associated with the same COM port.

Is there a way to uniquely identify a specific usb port on a host device?

This question may be very broad but I'm trying to keep it platform agnostic.
If I connect a device to a USB port on a computer, is there a way for that device to uniquely identify the port it's connected to?
e.g. I have a PC with 10 USB ports. I have a smart phone that's programmed to run Function A if it's connected to Port 1 and Function B if it's connected to Port 2, etc...
Is there a way that the smartphone (the peripheral in this case) can identify the specific port on the host?
Is there a way it can identify the host device as a whole?
Basically, does the peripheral know anything about the host?
Is there a way that the smartphone (the peripheral in this case) can identify the specific port on the host?
No, only the host knows which port a device is connected to. They all look the same from the phones point of view.
Is there a way it can identify the host device as a whole?
Basically, does the peripheral know anything about the host?
Not with USB per se, but you could implement some identification in a higher protocol.
Look at later implementations of the android debugging protocol for example: The host sends an ID to the device, and unless it matches in the device database the user will be asked: "Do you want PC (ID) to be able to debug this device?"

emulating usb device with another PC

Task: Testing production software on PC notebook without production unit attached via USB and without changing prodcution software.
Goal: Emulate production device with another PC. The test application runs on the second PC to emulate our device commands/responses.
Challenge: Using a USB bridge cable or other device requires that we can change the PID/VID to look like our device.
Suggestions?
You need a hardware device on the second PC to do this type of emulation.
USB ports on a normal PC are USB host ports. Two such ports cannot be connected with each other directly. USB device (or USB OTG - switchable) ports can be found on programmable smartphones (Android, maybe others) and some developer boards like these. I think you probably need to use a smartphone or developer board rather than ordinary PC as the your USB device emulator.

communication to usb port by using vc++2008

I want to communicate to halios system(hardware) through usb port. I have a code which shows that the device is attached. I used USBTrace which shows that how many bytes are going in and out from the device to the host. But I do not know how to implement this is vc++2008 and by using windows xp.
If this is an evaluation board for an Elmos optical sensor IC I would guess that a USB to serial converter is involved. You could confirm this by watching Windows Device Manager for a new COM port appearing when you attach the device.
If that's the case you can use Basic example of serial communication with Windows XP/win32 but you may need to contact Elmos for the command protocol.

Program hardware without Printer Port

My motherboard is small and don't have a printer port, all the tutorials (program LEDs, motor etc.) of hardware programming tell the use of this port or a USB to printer port converter to program hardware.
Is there any other way and any other port (for example USB) to program hardware?
I suggest to buy Arduino which can easily be connected to USB and use it's outputs as parallel port. Why parallel port is popular when working hardware? Because it can be easily controlled programmatically. With USB you can't just set certain bits. Bu Arduino comes with build-in USB support on one side and easily programmable output on another. Plus it is cool device by itself.
That depends on the hardware. If your hardware has a printer port (or parallel port, more specifically), you will need that one. If your hardware has a serial port (COM) which is quote common too, you need one of those. Some hardware will need the game/midi port that you used to plug in your joystick on your old 386 PC. I think convertors are available to convert USB to each of those ports.