Hi, I want to send chains of 12 bits of data through USB, but I'm completely new to USB programming. Say I type in "A", and it'll send 000000000001 or something like that.

Basically, I'm wondering how you tell the USB port to send a 0 or a 1 in C++. I'm writing with wascana eclipse, and I'm not sure what libraries to use.

This may be helpful for you (Windows only): http://msdn.microsoft.com/en-us/library/ms810467.aspx

This may also be helpful: http://www.libusb.org/

the first link gives information for programming serial ports right?

i've downloaded the libusb package, but one question I have is if you can control every bit that goes out individually. For example,

int main(){
for(;;)}
cin >> myinput
sendToUSB(myinput);
}
}

say I input 0101, can i have a procedure that sends out all logic 0's and 1's through a void procedure (below) as defined by USB convention? (0=600microseconds, 1=1200microseconds) Basically I need help writing that void procedure.

void sendToUSB(myinput)

the first link gives information for programming serial ports right?

i've downloaded the libusb package, but one question I have is if you can control every bit that goes out individually. For example,

int main(){
for(;;)}
cin >> myinput
sendToUSB(myinput);
}
}

say I input 0101, can i have a procedure that sends out all logic 0's and 1's through a void procedure (below) as defined by USB convention? (0=600microseconds, 1=1200microseconds) Basically I need help writing that void procedure.

void sendToUSB(myinput)

Also, the libusb specs say that you need to send a setup packet before the actual data package. It should be possible to send just a data package, without the setup packet in front of it right? I'm making a circuit that's going to interpret 12 bits which are sent out of the USB port at a time, and it'll be a lot easier if I don't have to mess around with the setup packet.

You can use a bitset to set your bits as needed.
see here: http://www.cplusplus.com/reference/stl/bitset/

Otherwise, I'm afraid I'm not a libusb expert, nor in working with USB.

I don't know if you want to send a 0 then a 1 in separate calls to the right function or send say an integer with bits set from a bitset.

Yeah, I know about bitset. I just need help with the actual USB programming part. Is there any way of sending out data payloads without any padding?

Also, is it possible to send data do a device that I built, even if the computer does not recognize it? Because I'm pretty sure once I connect my circuit it's going to be detected and windows won't have a driver for it.

Might have to write a driver or a mini driver.

If you're using Windows check out the DDK (Driver Development Kit). For devices like a mouse often only a mini-driver is required.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.