N
news.microsoft.com
Hi Experts, I need help with USB port.
The task is very simple: A cash register in a supermarket is connectd to a
receipt printer throuhg a USB cable. Instead, the cable should go from the
cash register to another computer. The raw printer data is processed (we are
not interested in the processing),and sent furthere (again, we don't care
wgere).
I am completely new to USB programing. I imagin the method should look like
this:
private void Handle USBData()
{
Read USB port from configuration; (1)
Do Forever
{
try to connect to port; (2)
if (SUCCESS)
{
// Exit Connect loop when connected
break;
}
// Read hand handle data
Do Forever
{
if (STOP flag is raised OR connection to port lost)
{
// If the user terminates the program, or something wrong
happend with the port - Stop
break;
}
Read from port;
Handle data;
}
}
As you see, I have three questions:
(1) - How are USB ports named?
(2) - How do I cvonnect to a USB port? Is is some kind of OpenFile() like
with serial port?
(3) - Ho do I read data from a USB port? (gues: some kind of Read() from a
file).
Is there a good code example (preferably C#, but not mandatory) that
demonstrate this task?
Thanks in advance
Boaz Ben-Porat
Milestone Systems A/S
Denmark
The task is very simple: A cash register in a supermarket is connectd to a
receipt printer throuhg a USB cable. Instead, the cable should go from the
cash register to another computer. The raw printer data is processed (we are
not interested in the processing),and sent furthere (again, we don't care
wgere).
I am completely new to USB programing. I imagin the method should look like
this:
private void Handle USBData()
{
Read USB port from configuration; (1)
Do Forever
{
try to connect to port; (2)
if (SUCCESS)
{
// Exit Connect loop when connected
break;
}
// Read hand handle data
Do Forever
{
if (STOP flag is raised OR connection to port lost)
{
// If the user terminates the program, or something wrong
happend with the port - Stop
break;
}
Read from port;
Handle data;
}
}
As you see, I have three questions:
(1) - How are USB ports named?
(2) - How do I cvonnect to a USB port? Is is some kind of OpenFile() like
with serial port?
(3) - Ho do I read data from a USB port? (gues: some kind of Read() from a
file).
Is there a good code example (preferably C#, but not mandatory) that
demonstrate this task?
Thanks in advance
Boaz Ben-Porat
Milestone Systems A/S
Denmark