Hello-
Let me open this post with a question. If the current (March 2011) USB implementation of libmaple
uses bulk transfer endpoints (which guarantees data integrity, but not bandwidth access), what is the LeafLabs test to see that this is true? Would a simple loop of SerialUSB.println('A')
which sends a gigabyte of data suffice? Of course, at the host/receiving end an application would have to test that all the characters received were capital As followed by the CR/newline.
gbulmer, I think we have unveiled many important questions about USB during our last few exchanges. We have answered many (of my) basic questions. Your observations have given me confidence that my growing knowledge is at least heading in the right direction.
After this post I may sit quietly about USB until I see what changes (eg. DMA) the LeafLabs team has planned for IDE 0.1.0. I may start a new topic related to how are functions (eg. USB) implemented by st.com on the chip in silicon and how does the libmaple (or software in general) access the hardware functions. The answers to these questions will determine how much further into USB I can dig.
However, as I edit this message I realize my understanding of endpoints (which we have not discussed very much) is beginning to solidify. Maybe I will start another topic on USB endpoints.
Back to USB transfer types. In one sentence I phrased a question poorly and also made a mistake (which was caught). Definitely not one of my best sentences. Previously, I said (including the mistakes):
For example, can a single device be configured to simultaneously use interrupt transfers (eg for low volume data transfers where data integrity is necessary) and bulk transfers (where a large amount of data needs to be transferred, but the absolute accuracy is not needed)?
Yes, I intended to say isochronous transfers. Of course, multiple communications cannot be simultaneous over a single wire, so a better way, fixing both mistakes, to phrase the previous sentence is:
For example, can a single device be configured to use both interrupt transfers (eg for low volume data transfers where data integrity is necessary) and isochronous transfers (eg where a large amount of data needs to be transferred, but the absolute accuracy is not needed)?
For example, can a USB device send some periodic low volume ADC measured information (eg. temperature) using interrupt transfer endpoints while it also "simultaneously" streams high volume audio (through isochronous transfers). Imagine yourself listening to music stored on a SD card connected to the Maple while you get the current temperature once every 5 seconds via a ADC temperature sensor.
Let me try to rephrase the question about assigning multiple COM ports to a single USB device. At the moment, my host system can communicate via USB with the Maple as COM7. However, in the Maple only bulk transfers are currently (March 2011) enabled. Is it theoretically possible (when interrupt transfers are enabled) to use both bulk transfers (COM7) and also interrupt transfers in the same Maple sketch? Will the host see the data arriving from the device as just COM7 or will another virtual COM port be enabled?
Another way to ask the question is this. The Maple currently (March 2011) use SerialUSB.print()
to access bulk transfers. If the device can be setup to use for example, both bulk and interrupt transfers what print command will be used to distinguish between the bulk and interrupt transfers?
If two SD cards are connected to the Maple, can they be configured to appear as two separate hard drives? Does this require that both host (eg. a host USB driver) and device (eg. libmaple USB drivers) be written? I am not planning to do this; just trying to think of examples to explain what I originally meant by "simultaneouslt".
Is this all wrapped up in endpoints and possibly multiple endpoints?
Regarding interrupt vs isochronous:
I'm not sure what you are planning, but CD is sampled at 44,100 Hz, in 16 bits, and stereo doubles that to get 176,000 bytes, quite a lot more than 57,000 bytes.
I forgot that CD music is 16-bit (2 bytes), so in my mind I was comparing 88K to 57K. However, 176K is only three times 57K. I think we can agree that 64,000 bytes/second can be a lot of data (even to a 32-bit cpu), depending on how much it has to be processed before it is sent over the communication line.
gbulmer says:
But that is only half the story. There needs to be a host-side driver which will use the transfer. If you're planning on writing your own host-side USB driver, then you can achieve a lot more. But we'd need to do some tests if the plan is to use existing drivers, and the USB spec's define the protocols, and hence which end points and transfer types are used.
No, I do not plan to write a host-side USB driver, but maybe I set it as a very long term goal if I understand what is meant by "achieve a lot more". What else can be achieved using USB 2.0 which is not currently implemented using the current host-side USB drivers? I assumed the current host-side USB drivers permit the maximum data transfer rates permitted by the USB 2.0 full speed spec. I assumed that during enumeration, when the device is first connected, as many endpoints are created as are needed/requested by the device.
Regarding control transfers and time intervals.
But it doesn't say there *MUST* be control transfers to every device in every frame.
I think we now agree that another way to ask the question is if control transfers occur during each interval?
I am still looking for a link which says that control transfer occur during each time interval.
I assumed control transfers were used during each interval so the host could tell each of the connected devices when they could send and receive data during that interval. I assumed control transfers acted like traffic cops.
I think we now agree that devices can set during enumeration when they want to be polled by the host. Let's assume two devices (deviceA and deviceB) each want to send a full 1023 byte isochronous type data packet every 2 milliseconds. My assumption is that during a specific interval the control transfer would be used by the host to tell say which device (A or B) could send its data packet and (by default) which device had to wait.
To make the situation more complicated lets assume each isochronous device wants to be polled every millisecond and send a full 1023 packet. What will happen in this situation? Will half of each device's data packets simply not get sent/received? If deviceA is sending a continuous tone to the left headphone (but silence to the right headphone) and deviceB is sending a continuous tone to the right headphone (but silence to the left headphone) will the host system compromise and jump back and forth between deviceA and deviceB (resulting in sound alternating every millisecond between the left and right headphones)?
I think we agree that for the interrupt/bulk transfer data types which are used for data whose integrity is maintained asking the device to wait a few frames or asking the device to resend data is essential to data integrity (but does not guarantee when data is transferred). With interrupt/bulk transfers the devices wait until the host says the pipes are clear.
Regarding bandwidth I also said:
However, the unpredictable bandwidth problem can be "solved" by simply using the Maple as the only device connected to the USB port.
This is what I was thinking. Imagine a bulk transfer device (such as a USB drive). Bulk communication is done after the control/interrupt/isochronous communications are completed. Whatever is left of each time interval (1 millisecond for full speed devices) is distributed to the bulk devices. If there are few or zero other interrupt/isochronous devices connected, most of the time available is used for bulk devices.
So in the current (March 2011) Maple USB implementation the use of bulk transfer endpoints should not limit the speed much as long as the Maple is the primary USB peripheral.
I remember days when a slow IDE CD ROM drive configured on a two drive cable as the "sl_ve" (I always hated the expression) could slow down the second device on the cable (configured as the "m_aster"). Is the observation/memory of slow USB devices slowing down the whole USB chain related to the USB 1.0 spec? Or perhaps does a single USB 1.0 device on a USB 2.0 hub slow down all the traffic to the 1.0 speed?
Let me quickly return to an old question, which I think we have now answered (over the course of several exchanges). Do we agree that during a single 1 millisecond time interval a device can send a single packet?
Is this related to why the transfer types which are error free (control/interrupt/bulk) have small data packets? If during the transfer 64 bytes of data become corrupted, requesting a resend of the data is not a big challenge to the system. However, for isochronous data transfers if the data is transferred with errors then a choice needs to be made by the host to either use the partially corrupted data or to wait until the next frame.
I think I need to read more about USB endpoints. More questions later.
Those are my thoughts for now.
Stephen from NYC (full disclosure: I am not a member of the LeafLabs staff)