1

Question: what more do I need to do to get a simple Arduino sketch to talk to JMRI/CMRI on a Rasp Pi 3 over a usb cable?

Problem: the Serial Port entry in CMRI preferences, /dev/ttyACM0 is red.

Setup:

Rasp Pi 3 - Raspian 8 (jessie) updated/upgraded today
 Java 1.8.0_65
 JMRI version 4.4-R1ccf76b
 lsusb shows Bus 001 Device 004 ID 2341:0042 Arduino Mega 2560R3 (CDC ACM) plus other devices (flash drive, keybd, wireless)

Sketch is a simple cut-down clone (20 lines) of a more complicated one (800+ lines) that works through the same cable to an HP laptop running Windows 10 & JMRI/CMRI, so I am familiar with the process.

I am able to upload the sketch from the Pi 3 to the Arduino when JMRI (PanelPro) is not running. (When PPro is running, the port entry in Arduino Tools is grayed out, as it should be.)

The Arduino resets when PPro starts, and the receive light flashes. CMRI monitor shows Transmit, bits xmitted, and Poll 0 (ie no receive). The Arduino however is not receiving, as the sketch waits for a CMRI light (cmri.get_bit, my handshake routine), and then does a cmri.set_bit, I have modified the sketch to just send, but again, no receive shows in CMRI monitor.

/dev/ttyACM0 is set for 57600 8N2, using minicom, as is the Arduino (Serial.begin(57600, Serial_8N2). Flow ctl is hdwr yes/softwr no (have tried no/no and no/yes)

(CMRI uses 2 stop bits!)

I have disabled console access to serial via raspi-config - interfaces - serial console - No.

I also entered

sudo gpasswd -a pi dialout  return: adding user pi to group dialout

sudo chmod 777 /dev/ttyACM0 return: blank

The following does receive data from an Arduino example sketch ("Hi Pi") thru the usb cable (when stop bits have been set back to 1).

python2
import serial
ser = serial.Serial('/dev/ttyACM0', 57600)
while 1 :
        ser.readline()

so it seems to be a CMRI port problem.

Can anyone suggest what I should do to get the 'red' out?

0

1 Answer 1

1

short answer - everything is now working. Switched from an Arduino Mega to a Nano, which forces ttyUSB0 (nano is ftdi interface). Also found several other ppl who cannot change Pi3 port configuration, so knuckled under to existing 9600 baud on both ends (C/MRI & Arduino). Also turns out stop bits seem to be a red herring. Arduino still set for Serial.begin(9600,SERIAL_8N2; but is able to send/receive on ttyUSB0 correctly.

Changed back to Mega (app needs more i/o than Nano provides), and was forced back to ttyACM0. C/MRI doesn't like to start with this port, so solution is to save JMRI panel file with the C/MRI node deleted. Once PanelPro starts, enable the port, and away we go.

2
  • Please can you accept your answer? Otherwise it will be pumped by Community even after years.
    – Ingo
    Commented Apr 10, 2018 at 14:45
  • @Ingo Acceptance isn't necessary (and it looks like the OP hasn't been here for a long time, anyway). Community will stop bumping if anyone votes on the post (up or down). It only bumps questions with no upvoted answers.
    – Aurora0001
    Commented Apr 10, 2018 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.