Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:59 19 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Serial console for CMM2 on Linux

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 09:05am 16 May 2020
Copy link to clipboard 
Print this post

In a separate thread issues were raised about using a serial console on Linux based computers to access the CMM2. In this thread I will explain how to do it in a way that works - or at least for me and TassyJim.

First you need to download and install the latest CMM2 firmware V5.05.02RC28 available from

http://geoffg.net/Downloads/Maximite/Colour_Maximite_2_MMBasic.zip

Make sure you refresh your browser so it downloads the new copy. This was updated at 09:00 GMT on the 16/05/20

Then install PUTTY

On the Raspberry Pi the command for this is:

sudo apt-get install putty


Now follow the instructions on the Microchip website for using LINUX with their MCP2221A USB/UART chip (NB this also works exactly the same for a Microbridge equipped CMM2). This has been tested on a Pi4 running Raspbian Buster.

  Quote  
MCP2200/MCP2221 - Linux Driver Instructions

In order to be able to use the MCP2200/MCP2221 with Linux, the kernel must have support for USB CDC class drivers.
The cdc_acm driver is used for the CDC interface of the device.
If the cdc_acm driver is compiled as a module, when plugging the MCP2200/MCP2221, this driver will be loaded by the kernel.

To verify that, type:

lsmod | grep cdc

or you can verify it like this:

dmesg | grep ttyACM

After that, there will be an entry in /dev

in order to find the entry type:

ls /dev/ttyACM*

If there are any issues, there will be no entries. But if everything goes well we should see something like:
/dev/ttyACM0

In order to be able to use your favourite terminal program, we will create a link between /dev/ttyACMx and a serial port.
To do that just type:

sudo ln -sf /dev/ttyACM0 /dev/ttyS3

In some other systems, there might be a different number after "ttyACM". You have to provide the number that
appears in your system. As for the "ttyS3", I had chosen this one since it was an unused serial device node.
Now, let's make some settings on the serial port. Use "stty" to set serial port parameters. E.g. :

sudo stty -F /dev/ttyS3 115200

You can start now whatever serial port utility you want - Putty


On some LINUX installs (not Raspbian) the system includes a modem manager that tries to treat any ACM device as a modem and sends unwanted characters to it during initialisation. Unless you are actually using a modem then disable this completely

sudo systemctl stop ModemManager.service
sudo systemctl disable ModemManager.service


Run PUTTY and it should then work as expected. Don't change any of the defaults. The keyboard and function key setting should be

ESC[n~

Hope this helps - please report any issues.
Edited 2020-05-16 19:09 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 03:50pm 16 May 2020
Copy link to clipboard 
Print this post

Thank you Peter,

I can confirm that RC28 fixes the issue for:

RPi 3 Model B+
 Raspbian GNU/Linux 9 (stretch)
 Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Putty 0.67 (which is the current version for this Raspbian distribution)

  Quote  
sudo ln -sf /dev/ttyACM0 /dev/ttyS3
sudo stty -F /dev/ttyS3 115200


I'm a "monkey see, monkey do" kind of guy when it comes to anything system-level but I have strong suspicions that the above is unnecessary when using PuTTY and (if of any use at all) is applicable to using a command line serial terminal from Linux.

- the first line creates a symbolic link from /dev/ttyS3 -> /dev/ttyACM0.
- presumably so that the second line can set the baud specifically for use via ttyS3 rather than all uses of ttyACM0.

HOWEVER my reading of the internet suggests 'stty' calls are not persistent across reboots, and I haven't been setting it each time, and I've now deleted my /dev/ttyS3 link and using /dev/ttyACM0 directy still works with PuTTY.

I believe that for PuTTY on Raspbian (and probably Linux in general) all you need to do is (though the PuTTY UI):

1. Set "Connection type" -> "Serial"
2. Set "Serial line" -> /dev/ttyACM0
3. Set "Speed" -> 115200
4. Set "The Backspace key" -> Control-H
5. Set "The Function keys and keypad" -> ESC[n~
6. Optional: set window size 100 x 50
7. Optional: set the colour for the ANSI Blue code to something lighter as the default is unreadable on a black background

Now I've got some working tooling I can start bashing the CMM2 properly.

Thanks again,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 04:04pm 16 May 2020
Copy link to clipboard 
Print this post

It's also worth noting that PuTTY (at least on Linux) allows multiple connections to the same serial port !!!

You don't want to do this, but if having got it working for the first time you then find you start getting nonsense in the output it's possibly because you've connected another instance without closing the first.
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5882
Posted: 09:55pm 16 May 2020
Copy link to clipboard 
Print this post

  thwill said  

I believe that for PuTTY on Raspbian (and probably Linux in general) all you need to do is (though the PuTTY UI):

1. Set "Connection type" -> "Serial"
2. Set "Serial line" -> /dev/ttyACM0
3. Set "Speed" -> 115200
4. Set "The Backspace key" -> Control-H
5. Set "The Function keys and keypad" -> ESC[n~
6. Optional: set window size 100 x 50
7. Optional: set the colour for the ANSI Blue code to something lighter as the default is unreadable on a black background



8. set the serial handshaking to "none"
9. set the font small enough to make sure that your 50 lines fit on your display. Putty does strange things if it decides to resize your terminal for you.

I agree with using /dev/ttyACM0 directly.
I think that the reason for using the symbolic link to a standard serial port is to prevent some comms programs from sending modem control codes.
I had a lot of trouble with the ModemManager.service on my Linux PC probing the port.

Jim
Edited 2020-05-17 07:55 by TassyJim
VK7JH
MMedit   MMBasic Help
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3496
Posted: 06:56am 18 May 2020
Copy link to clipboard 
Print this post

  thwill said  It's also worth noting that PuTTY (at least on Linux) allows multiple connections to the same serial port !!!

You don't want to do this, but if having got it working for the first time you then find you start getting nonsense in the output it's possibly because you've connected another instance without closing the first.


This is a very handy feature !! I use expect scripts using CU to control devices through serial port, and by having Putty opened, I can intervene if a script runs off.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024