Comments (18)
The specification requires bDataBits to be either 5, 6, 7, 8, or 16. If the host sends a packet with bDataBits of 0, then that is an invalid packed, and the device correctly rejects it by stalling the pipe.
See "Universal Serial Bus Communications Class Subclass Specification for PSTN Devices, Revision 1.2, February 9, 2007", page 25.
from libopencm3-examples.
I know that the behavior of Windows is not standard conform. But it is also frustrating if you try an example and it doesn't work. I was lucky that i have access to a USB analyser. So it was not a big deal to find the problem. Maybe a little hint in the readme is ok for you.
For me it is ok to stick to the specification and left the example as is.
from libopencm3-examples.
USB analyzer or Wireshark should work. I don't know how the Windows driver model works and how they changed it since I last looked at it, but sounds like an issue with the *.inf file.
Feel free to submit a pull to update the README.
from libopencm3-examples.
I think it is not a problem with the inf file. The CDC device gets enumerated and a serial port is available. As soon as i try to open the serial port Windows send a bad SET_LINE_CODING with only the baudrate valid. If the device rejects the request after some retries Windows fails with an error. If the request is acceted Windows will send more SET_LINE_CODING requests with correct values.
I dont like such workaround as the the windows driver do not conform to the standard. But i need it to work under Windows. I am open for better solutions.
from libopencm3-examples.
I see three options:
- File a bug report with microsoft.
- Ignore bad packet in your project, but don't STALL the endpoint.
- Write a custom driver.
However, I would rather not merge non-compliant code in the examples dir.
The SetLineCoding request is optional for CDC ACM, so I have no idea why windows just quits when it STALLs.
from libopencm3-examples.
If you can upload USB capture files (PCAP format) to somewhere public, I'd be interested to have a look.
from libopencm3-examples.
Is Wireshark under Windows able to capture USB ?
from libopencm3-examples.
AFAIK, you need to capture it with winpcap, and Wireshark will be able to open the capture file postmortem. I don't know if there is a faster method to do this natively.
Does your USB analyzer software support exporting to pcap format? That might be easiest for you.
from libopencm3-examples.
Currently i am at home. I will try with USBpcap and Wireshark at home. Tomorrow i can hava a lokk at the USB analyzer.
from libopencm3-examples.
Last time I had to do this kind of stuff, I used a linux host with windows VM, and just used usbmon on the host with Wireshark.
from libopencm3-examples.
Now there is USBpcap for Windows. I have captured to files.
- lm4f_example_error.pcap (http://www.everwait.de/usb/lm4f_example_error.pcap)
- lm4f_example_always_ack.pcap (http://www.everwait.de/usb/lm4f_example_always_ack.pcap)
The first is the original example and the second returns always ok on SET_LINE_CODING .
from libopencm3-examples.
Tomorrow i will try to export the data from the USB analyzer. I think the output from the analyzer is much better.
from libopencm3-examples.
Crap. winpcap didn't capture the setup packets. Can't tell what usbser.sys tried to do with all those SetLineCodingRequets. I suspect it is probing the capabilities, but that is a very wrong way to do it.
from libopencm3-examples.
The export capabilities of the analyzer software are not very helpfull. I will attach a screenshot of the captured data. The capture shows two tries with different baudrate. The SET_LINE_CODING requests are expanded in the view.
Hope that helps.
from libopencm3-examples.
Yeah. Just what I thought. It tries 115200 baud, and when that fails, 9600 baud. It probes the supported capabilities one at a time. They must have figured that since 0 is a valid value for bCharFormat and bParityType, it should be valid for bDataBits, which is of course, a bad assumption.
I'm curious about the capture when the device doesn't stall.
from libopencm3-examples.
Not Windows is probing. I have probed with two different settings. When i try to open the port with 115200 Windows returns an error and i am unable to open the port.
from libopencm3-examples.
It sends a GetLineCoding request right after the failed SetLineCoding request. This is what we call the
i=5; i=5; i=5; //Make sure i is 5 or the code below will crash
syndrome. The STALL is meant to indicate that that the request has failed, so asking the device for the parameters is futile, since no parameters were set in the first place. GetLineCoding is also sent more than once, perhaps in the hope that the device has not yet had time to respond, but will do so soon in the future. This tells me that whoever wrote the usbser.sys driver did not understand USB and the CDC ACM protocol well enough.
The obvious solution is to set bDataBits to 8 if it is received as 0, but since this violates the official protocol, I would rather not have this in the example.
Documenting the stupid things that some OSes do, along with a small set of modifications that could be done to make the device work is the preferred option. It should eliminate the frustration of "it doesn't work" because we know "how to make it work".
from libopencm3-examples.
Document the stupid things is for me the best solution. It is better the example do not violate the standard.
Thank you for your patience and help.
from libopencm3-examples.
Related Issues (20)
- STM32F446 example for usb HOT 4
- Using program_erase_flash in USB devices on STM32F1 (e.g. DFU example) HOT 9
- usb_cdcacm example on STM32F303RD not working HOT 2
- stm32: FLASH_BASE only defined for F0/F1 HOT 1
- Add g0 examples HOT 1
- stm32F070 USB
- target memory segment string descriptor
- arm-none-eabi-gcc not found error HOT 7
- Unable to run elf files HOT 5
- Nucleo-F429ZI USB HOT 1
- A question about rfid driver HOT 2
- Current build fails HOT 1
- using stm32f103c8 test HOT 1
- Composite USB device example HOT 7
- stm32f429i-dicovery ltdc example gpio setup HOT 1
- Can not flash stm32vl-discovery via `make flash` in the fancyblink example HOT 1
- How stm32F429IGT6 use st-link and openocd to burn miniblink.elf ? HOT 8
- Examples are difficult to find with much duplication HOT 1
- API differs significantly between target microporcessors HOT 1
- I2C examples are broken?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libopencm3-examples.