On Monday, December 5, 2022 at 9:30:24 PM UTC-5, anti...@math.uni.wroc.pl wrote:
> Rick C <gnuarm.del...@gmail.com> wrote:
> > On Sunday, December 4, 2022 at 10:33:28 PM UTC-5, anti...@math.uni.wroc.pl wrote:
> > > Rick C <gnuarm.del...@gmail.com> wrote:
> > > > On Sunday, December 4, 2022 at 4:30:35 PM UTC-5, anti...@math.uni.wroc.pl wrote:
> > > > > Rick C <gnuarm.del...@gmail.com> wrote:
> > > > > > On Wednesday, November 30, 2022 at 9:08:25 PM UTC-4, anti...@math.uni.wroc.pl wrote:
> > > > > > > Rick C <gnuarm.del...@gmail.com> wrote:
> >
> > > > > > > With relatively cheap convertors
> > > > > > > on Linux to handle 10000 roundtrips for 15 bytes messages I need
> > > > > > > the following times:
> > > > > > >
> > > > > > > CH340 2Mb/s, waiting, 6.890s
> > > > > >
> > > > > > That's 11.3 per target, per second. (128 targets)
> > > > > >
> > > > > > > CH340 2Mb/s, overlapped 1.058s
> > > > > >
> > > > > > That's pretty close to 74 per target, per second.
> > > > > >
> > > > > > I used to use the CH340 devices, but we had intermittent lockups of the serial port when testing all day long. I switched to FTDI and that went away. I think you told me you have no such problems. Maybe it's the CH340 Windows serial drivers.
> > > > > Well, my use is rather light. Most is for debugging at say 9600 or
> > > > > 115200. And when plugged in convertor mostly sits idle. I previously
> > > > > wrote that CH340 did not work at 921600. More testing showed that
> > > > > it actually worked, but speed was significantly different, I had to
> > > > > set my MCU to 847000 communicate. This could be bug in Linux driver
> > > > > (there is rather funky formula connecting speed to parameters
> > > > > and it looks easy to get it wrong). Similary, when CH340 was set to 576800
> > > > > I had to set MCU to 541300. Even after matching speed at nomial
> > > > > 576800, 921600 and 1152000 test time was much (more than 10 times)
> > > > > higher than for other rates (I only tested 1 character messages at those
> > > > > rates, did not want to wait for full test). Also, 500000 was significantly
> > > > > slower than 460800 (but "merely" 2 times slower for 1 character messages
> > > > > and catching up with longer messages). Still, ATM CH340 looks
> > > > > resonably good.
> > > >
> > > > Yes, it's reasonably good for situations where it does not need to work reliably. I was surprised when the finger was pointed to the CH340 adapter. But someone (probably here) had warned me they are not dependable, and now I know. The cost of a name brand adapter is not so much that it's worth saving the difference, only to have to throw it out and go with FTDI anyway, when you have real work to do.
> > > Well, I say you what I observed. People say various thing on the
> > > net. I was interested if net know something about my trouble with
> > > CP2104 so I googled for "CP2104 lockup". And I got a bunch of
> > > complaints about FTDI devices, solved by using CP2104. So, there
> > > is a lot of noise and ATM I prefer to stay with what I see.
> >
> > What sort of complaints about FTDI? Did you contact them about it?
> Things like computer locking up (IIUC fixed by newer driver). Or
> "communication did not work" (no real info). ATM I have enough
> converters. If I need more/better I will look at FTDI products
> and possible ask them questions.
> > > > > Remark: I bought all my convertors from Chinese sellers. IIUC
> > > > > FTDI chip is faked a lot, but other too. Still, I think they
> > > > > show what is possible and illustrate some difficulties.
> > > >
> > > > FTDI fakes no longer work with the FTDI drivers. Maybe they play a cat and mouse game, with each side one upping the other, but it's not worth the bother to try it out. FTDI sells cables. It's easier to just buy them from FTDI.
> > > AFAIK Linux driver does not discriminate againt non-FTDI devices.
> > > So fact that convertors works with Linux driver tells you nothing
> > > about its origin. And for the record, I bought mine several years
> > > ago.
> >
> > I'm not using Linux. I don't have any FTDI fakes. I have some Prolific fakes somewhere, if I could find them. I never had one bricked, but I think it was Prolific that did that some years ago. Or, I may have them confused with FTDI. I remember the bricking driver was released with a Windows update and MS was pretty pissed off when the bricking hit the news.
> It was FTDI who bricked fakes, that was widely discussed. I did not
> hear about Prolific doing something like that.
> > > > > > > CP2104 2Mb/s, waiting, 2.514s
> > > > > > > CP2104 2Mb/s, overlapped 1.214s
> > > > > >
> > > > > > I don't know what the CP2104 is.
> > > > > It is a chip by Silicon Laboratories. Datasheet gives contact address
> > > > > in Austin, TX.
> > > > > > I'm not certain what "overlapped" means in this test. Did you just continue to send 15 byte messages with no delays 10,000 times?
> > > > > No. My slave simply returns back each received character. There is
> > > > > some software delay but it should be less than 2us. So even waiting
> > > > > test has some overlap at character level. To get more overlap above
> > > > > I cheated: my test program was sending 1 more character than it should.
> > > > > So sent message was 16 bytes, read was 15. After reading 15 another
> > > > > batch of 16 was sent and so on. In total there were 10000 more
> > > > > characters sent than received. My hope was that OS would read
> > > > > and buffer excess characters, but it seems that at least for
> > > > > CP2104 they cause trouble. My current guess is that OS is
> > > > > reading only when requested, but I did not investigate deeper...
> > > > > > Since you are in the mood for testing, what happens if you run overlapped, with 128 messages of 15 characters and wait for the replies before sending the next batch? Also, if you don't mind, can you try 20 character messages?
> > > > > OK, I tried modifeed version of my test program. It first sends
> > > > > k messages without reading anything, then goes to main loop where
> > > > > after sending each message it read one. At the end it tail loop
> > > > > which reads last k messages without sending anything. So, there
> > > > > is k + 1 messages in transit: after sending message k + i program
> > > > > waits for answer to message i. In total there is 10000 messages.
> > > > > Results are:
> > > > >
> > > > > CH340, 15 char message 20 char message
> > > > > k = 0 6.869s 7.163s
> > > > > k = 1 4.682s 1.320s
> > > > > k = 2 0.992s 1.320s
> > > > > k = 3 0.991s 1.319s
> > > > > k = 4 0.991s 1.320s
> > > > > k = 5 0.990s 1.319s
> > > > > k = 8 0.992s 1.320s
> > > > > k = 12 0.990s 1.320s
> > > > > k = 20 0.992s 1.319s
> > > > > k = 36 0.991s 1.321s
> > > > > k = 128 0.991s 1.319s
> > > > >
> > > > > CP2104, 15 char message 20 char message
> > > > > k = 0 2.508s 3.756s
> > > > > k = 1 1.897s 1.993s
> > > > > k = 2 1.668s 2.087s
> > > > > k = 3 1.486s 1.887s
> > > > > k = 4 1.457s 1.917s
> > > > > k = 5 1.559s 1.877s
> > > > > k = 8 1.455s 1.803s
> > > > > k = 12 1.337s 1.501s
> > > > > k = 20 1.123s 1.499s
> > > > > k = 36 1.125s 1.502s
> > > > >
> > > > > k = 128 reliably stalled, there were random stalls in other cases
> > > > >
> > > > > FTDI232R,
> > > > > 2 Mbit/s 15 char message 20 char message
> > > > > k = 0 5.478s 3.755s
> > > > > k = 1 4.929s 3.030s
> > > > > k = 2 2.506s 3.339s
> > > > > k = 3 2.459s 2.020s
> > > > > k = 4 1.708s 1.061s
> > > > > k = 5 1.671s 1.032s
> > > > > k = 8 0.764s 1.021s
> > > > > k = 12 0.772s 1.014s
> > > > > k = 20 0.763s 1.009s
> > > > > k = 36 0.758s 1.007s
> > > > > k = 128 0.757s 1.008s
> > > > >
> > > > > FTDI232R,
> > > > > 3 Mbit/s 15 char message 20 char message
> > > > > k = 0 8.216s 10.007s
> > > > > k = 1 5.006s 4.344s
> > > > > k = 2 3.338s 1.602s
> > > > > k = 3 2.406s 1.444s
> > > > > k = 4 1.766s 1.316s
> > > > > k = 5 1.599s 1.673s
> > > > > k = 8 1.040s 1.327s
> > > > > k = 12 1.071s 1.312s
> > > > >
> > > > > With k = 20, k = 36 and k = 128 communication stalled.
> > > >
> > > > Some of the results seem odd, hard to understand, like why the message rate improves so much as k is increased, but so dramatically at 3 Mbps. They all seem to approach ~1.3 second as k increases. At k=0 they are around 1 ms per message, which is the polling rate... if you adjust it. I think the default for FTDI was 8 ms.
> > > Let me first comment 2Mbit/s results. FTDI transfers data in 64-byte
> > > blocks (they say that actual payload is 62-bytes and there are 2-bytes
> > > of protocol info). With 15 characters messages 0.764s really means
> > > 98% of use of serial bandwidth, so essentiall as good as possible.
> >
> > Yeah, I'm not following that at all. At k=8, the 2 Mbps FTDI transferred in 1.021s. What is 0.764s???
> It seems that your news agent messed formating of tables. I gave
> results in two columns, one column for 15 character messages, second
> for 20 character messages. 0.764s is for 15 character messages,
> 1.021s is for 20 character messages.
Yes, I see that now. Google Groups removes excess spaces. Not a good idea and for no apparent reason. If they want to conserve bytes, maybe they should delete the message contents. That would greatly reduce the noise and only reduce the signal slightly in many cases.
> > > Corresponding k = 8 means really 9 messages in transit, so 135
> > > characters which is slightly more than 2 buffers. More data in
> > > transit does not help, but also does not make things worse.
> > > With 20 charaster messages main improvement is at k = 4 which
> > > means 100 characters, which is smaller than 2 buffers, with extra
> > > improvements for more data in transit. With CH340 and 15 char
> > > messages we see main improvement for k = 2, which corresponds
> > > to 45 characters in transit. With 20 char messages we get
> > > impovement for k = 1 which is 40 charactes in transit.
> > > CH340 uses 32 character transfer buffers, so improvemnet corresponds
> > > to somwhat more than 1 buffer in transit. Now, if transfers
> > > between converter and PC were at optimal times, then one buffer
> > > + one character would be enough to get full serial speed. But
> > > USB tranfers can not be started at arbitrary times, IIUC there
> > > are discrete time slots when transfer can occur. When tranfer
> > > can not be done in given slot it must wait for next slot.
> > > So, depending on locations of possible slots more buffering
> > > and more data in transit may be needed for optimal performance.
> > > OTOH 2-3 buffers should be enough to allow PC to get full
> > > bandwidth and this is in good agreement with FTDI results.
> > > In case of CH340 there is extra factor: CH340 also uses 8 byte
> > > transfers. I do not know what function they have, but
> > > resonably likely guess is that those 8 byte pack tranfer control
> > > info that FTDI bundles with normal data. Anyway, those
> > > are "interrupt" tranfers in USB sense, so have higher priority
> > > than data transfer. Resonable guess it that they steal some
> > > USB bandwith from data tranfers. Also, smaller than maximal
> > > data block size limits efficiency, so it is possible that
> > > CH340 is limited by USB bandwith (lack of enough slots).
> > >
> > > Now, concerning 3 Mbits/s, due to different serial speed
> > > optimal times for transfers are different than in 2 Mbits/s
> > > case. It is possible that there is worse fit of desired
> > > and possible transfer times. Buffering allows to at least
> > > partially cure this, so initial improvement. But clearly,
> > > there is some extra bottleneck. Now some speculation:
> > > with 1/8 ms USB-2.0 cycle, there is 1500 FS clock per
> > > cycle. I would have to look at spec to be sure, but this
> > > is close to 150 byte worst case FS transfer. Beside data
> > > there is some USB protocol overhead and (speculatively) it
> > > is possible that low level USB diver may refuse to schedule
> > > two 64-byte transfers in single cycle. In such case effective
> > > bandwith for serial data would be 4096000 bits, which
> > > correspond to 5120000 serial bits (serial sends start and stop
> > > bits which are not needed for USB). This is less than
> > > full duplex 3 Mbits/s (both directions add to 6 Mbits/s and
> > > must go trouh the same USB). With larger amount of data in
> > > transit this could give wild oscilations in amount of
> > > buffered data, leading to slowdown when buffers get empty
> > > and giving stall when receive buffer overflows.
> > >
> > > Of course there is another speculation: convertor may be fake.
> > > Supposedly fakes use MCU-s with special program. Software
> > > could crate delays which limit transfer rate at 3 Mbits/s
> > > and lead to data loss/stall with more data in transit.
> I last part I was partially wrong. USB-2.0 spec says that transmission
> between PC and high speed hub is always high speed. For full speed
> devices hub is supposed to buffer messages and transmit to device
> at its speed. In effect PC needs two high speed messages per low
> speed message. My tests above was with converter connected via
> high speed hub. There was also Stlink dongle plugged into the
> same hub. To remove effect of hub I tried plugging converter
> directly into USB-1.1 port on separate USB controller. That
> led to significantly longer times. I also tried to connect Stlink
> into separate port so that converter was the only thing connected
> to the hub. I run several times few cases at 3 Mbits/s, for short
> messages and low k results vary significanlty,
> for 120 characters and k = 0 I got times from 6.375s to 6.598s.
> At 2 Mbits/s in 25 runs I got one outlier at 6.667s, the rest
> was between 6.029s and 0m6.049s.
>
> Anyway, USB seem to have significant impact on possible speed,
> with full speed convertor and full duplex trasmission 2 Mbits/s
> seem to give better speed than 3 Mbits/s. Maybe better USB
> hub could help (I do not know how to find out size of buffers
> in my hub, but by the spec hub may have buffers just for 2
> bulk transfers or mauch more).
I would not be using a hub at all. This PC would be dedicated to testing and only a mouse would use a USB in addition to the serial dongle. Oh, I think they use a bar code scanner too, so three USB ports.
> Given the above I would expect
> convertor connected via high speed USB to perform better at 3 Mbits/s.
> > Reading your tests has made me realize, that while combining the messages for every target into one batch can be a bit unwieldy, I could limit the combinations to the end points on a single card. The responses have to be combined for the one driver anyway. Between the 8 end points on a single board I could easily combine those commands, and then stagger the replies without any extra signals between the boards and no special characters in the command stream.
> >
> > Again, thinking out loud, at 3 Mbps, 8 * 150 bits per command is 1,200 bits or 400 us. That would greatly reduce the wasted time, even with a 1 ms polling period. It would allow an exchange of 8 commands and 8 replies every 2 ms, or 4,000 per second. That would be almost 32 per end point, which would great! Actually, it could be faster than this, since the staggering of the replies, doesn't require the first reply to wait for the last command. So replies will start at the end of the first command. The beauty of full-duplex!
> >
> > Any chance you could run your test on the FTDI cable at 3 Mbps with a 1,200 bit block of data (120 characters)? I imagine the RS-232 waveform is getting a bit triangular a that speed.
> See above. Note that my test slave started replay after receiving first
> character. ATM it seems that with enough overlap at 2 Mbits/s I getting
> repeatably almost optimal speed (even with 1.1 port). But with less
> overlap there are randomly looking variations, which probably means
> high sensitivity to precise timing of messages. And at 3 Mbits/s
> variation seem to be much worse.
The priority protocol I described above would overlap after one message. So not a lot of difference.
Thanks for the info. It was very useful.
--
Rick C.
+-- Get 1,000 miles of free Supercharging
+-- Tesla referral code - https://ts.la/richard11209