I own a charger (iCharger 206B from Junsi) which has a USB interface (internally working with a CP210x chip form Silicon Laboratories). The baud rate is fixed to 128000 Baud and this seems to be a problem for Linux (non standard baudrate).

Windows on the other hand supports this with no problem at all.

Is there a way to get a 128000 baudrate in linux? When I try for example moserial and set the baud rate to 128000 baud it just crashes a few seconds later.

Using picocom from the terminal gives me a little more information about the problem:

As you are on a USB slot the the device will probably be /dev/ttyUSBx OR /dev/ttyACMx whre x = 0 to 7.

How to find what it is:-
(Assumptions; you are in a Linux, root mode terminal, etc.)
1) Ensure the device is disconnected...
2) ls /dev/*tty*
3) Connect the device and allow a few seconds to settle.
4) ls /dev/*tty*
5) Scroll the terminal to see the diff's...

Bazza wrote:How to find what it is:-(Assumptions; you are in a Linux, root mode terminal, etc.)1) Ensure the device is disconnected...2) ls /dev/*tty*3) Connect the device and allow a few seconds to settle.4) ls /dev/*tty*5) Scroll the terminal to see the diff's...

Yes I could do that, or use a Microcontroller to do that, but I really dislike the fact that Linux isn't able to handle this serial speed even if it is technical possible and needed from the user standpoint.

uli wrote:I own a charger (iCharger 206B from Junsi) which has a USB interface (internally working with a CP210x chip form Silicon Laboratories). The baud rate is fixed to 128000 Baud and this seems to be a problem for Linux (non standard baudrate).

You could of course petition Junsi to release a trivial firmware modification to change the 206B to use 115200 bps instead of 128000 bps...

As you know (since it works in Windows) your hardware is capable of handing 128000 bps; the problem is that getting a request for this speed through all the layers of library and kernel between an application program and the hardware would require changes to many different packages, and worse, changes to various standards. I can't see it happening unless there was a very popular product that needed it.

However, given Linux is open source, you can fairly easily do it yourself, and indeed I did it on my own system so that I could use that exact same model of battery charger!

I couldn't be bothered with all the changes that would have been needed to add proper support for B128000. Instead, what I did was to take over one of the existing speeds that I never used for anything else (I chose B230400), and then modified the cp210x.c kernel module source file so that when it was told to run at 230400 bps it actually used 128000 bps. The change to cp210x.c (from /usr/src/linux-source-3.5.0/drivers/usb/serial/cp210x.c) is quite trivial:

So now I just ask for 230400 bps and get 128000 bps, which works perfectly with the 206B charger.

By the way, if you don't want to rebuild an entire kernel, you can use DKMS. It is probably getting a bit off-topic, but (once you install all the necessary kernel source and development tool packages) you just create a directory (say /usr/src/cp210x-0.09k128) and put in it thee files: the patched cp210x.c, dkms.conf which looks like: