rckanta
Posts: 50
Joined: Tue Feb 18, 2020 2:00 pm

How can I send raw data (bits or Bytes) to USB?

Sat May 23, 2020 6:00 am

How can I send raw data (bits or Bytes) to USB?

D+ is a USB data output.
D- is a USB data input.

I want to send a raw frame to D-.
And I want to read a raw frame from D+?

Many people use USB to TTL Serial converter.
I don't like to use convert.

I know we can configure the USB port in this mode because USB is controlled by the processor.
We can control the processor by software.
In this case, Assembly language and C language can control the USB pin.

User avatar
rpdom
Posts: 16797
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: usb

Sat May 23, 2020 6:06 am

No, that is not the way the USB port is controlled.

It is a USB port with USB driving hardware. You can't change that.
Unreadable squiggle

Heater
Posts: 15518
Joined: Tue Jul 17, 2012 3:02 pm

Re: usb

Sat May 23, 2020 7:43 am

You cannot wiggle the data lines of USB like that. They are not GPIO pins. They a driven by a hardware USB circuit.

Even if you could you would find it next to impossible to wiggle those pins fast enough to talk to any standard USB peripheral.

Even if you could do that you would have to write all the code for the USB communications protocol. That is not a small or pleasant job: https://www.beyondlogic.org/usbnutshell/usb1.shtml The specification is a huge document.

If you don't actually want to talk to standard USB devices or use the USB protocol then why not just use a couple of GPIO pins to do what you want? If you want a regular serial link without a USB adapter why not use the UART on the Pi's GPIO pin header?

I guess you could write your own driver for the Pi's USB hardware, then you could probably instruct it to send and receive packets whenever and how ever you like. With total disregard of the actual USB protocol. In which case get a copy of the Linux kernel source code and have a look at the existing USB driver module.
Memory in C++ is a leaky abstraction .

User avatar
rin67630
Posts: 1013
Joined: Fri Mar 04, 2016 10:15 am

Re: usb

Sun May 24, 2020 5:25 am

Heater wrote:
Sat May 23, 2020 7:43 am
You cannot wiggle the data lines of USB like that. They are not GPIO pins. They a driven by a hardware USB circuit.
...and it requires an extremely stringent timing, usually requiring an own quartz to get it accurate enough.

User avatar
rin67630
Posts: 1013
Joined: Fri Mar 04, 2016 10:15 am

Re: usb

Sun May 24, 2020 7:50 am

rckanta wrote:
Sat May 23, 2020 6:00 am
D+ is a USB data output.
D- is a USB data input.
No. D+ and D- are a differential pair.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12873
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: How can I send raw data (bits or Bytes) to USB?

Sun May 24, 2020 12:59 pm

rin67630 wrote:
Sun May 24, 2020 7:50 am
No. D+ and D- are a differential pair.
And the communication on them is bidirectional

What you are trying to do is impossible! USB communication is done on the basis of an "endpoint device", (in a device class) you can only communicate with an end point device, an example is the "legacy serial" device, or the block storage device.....

I would first try to learn a bit more how USB actually works, because the way you think it works is a fantasy!

start by using Wikipedia, https://en.wikipedia.org/wiki/USB

also read this https://microchipdeveloper.com/usb:endpoints

Also stop spamming the forum with almost identical questions, if you don't you will get increasingly longer bans, because people will start to complain.

User avatar
topguy
Posts: 6369
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I send raw data (bits or Bytes) to USB?

Mon May 25, 2020 10:12 am

How can I send raw data (bits or Bytes) to USB?
What problem are you trying to solve with this ( more or less impossible ) solution ?

hippy
Posts: 7177
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How can I send raw data (bits or Bytes) to USB?

Mon May 25, 2020 11:28 am

topguy wrote:
Mon May 25, 2020 10:12 am
How can I send raw data (bits or Bytes) to USB?
What problem are you trying to solve with this ( more or less impossible ) solution ?
My guess would be this -
rckanta wrote:
Thu May 21, 2020 5:36 pm
I have a finger sensors module, it supports USB and UART communication.
USB communication gives better image resolution than UART.

I want to access(send and read) it from USB.
How to a C program to access USB?

User avatar
topguy
Posts: 6369
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I send raw data (bits or Bytes) to USB?

Mon May 25, 2020 11:51 am

One can always use https://libusb.info/ . Chances are it is quite unnecessary to use, but without any information about make/model or datasheet describing the USB interface we are just guessing.

Return to “C/C++”