Trobule with starting serial connection

Hi. I have my Raspberry Pi 1 B (minibian, OF 0.9.2) connected with 2nd device using UART ports with MAX3232 (TTL to RS232). ttyAMA0 login is disabled, tested the serial communication with minicom and works great. Each time I press button on the 2nd device I receive the message on my RPi.

Problem starts when I want to do the same thing with ofSerial. No communication, log says that all is OK:

[notice ] ofSerial: opening /dev/ttyAMA0 @ 9600 bps
[notice ] ofSerial: opened /dev/ttyAMA0 sucessfully @ 9600 bps

The only way to force OF to receive messages is to run minicom and quit it without reseting the connection (Ctrl+A, Z, Q). Then OF works as it should.

Is there something that I’m missing?

Also when running minicom or OF for the first time after reboot I get uart-pl011 20201000.uart: no DMA platform data.

.h file:

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp{
	
	public:
		void setup();
		void update();
		void draw();
		void keyPressed(int key);
		void keyReleased(int key);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
		
		ofSerial	mySerialConnection;
		ofTrueTypeFont myfont;
};

.cpp file:

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
	ofSetVerticalSync(true);
	myfont.loadFont("arial.ttf", 32);
	mySerialConnection.setup("/dev/ttyAMA0", 9600);
}

//--------------------------------------------------------------
void ofApp::update(){
	
}

//--------------------------------------------------------------
void ofApp::draw(){
	string diagnostics;
	diagnostics += "Bytes wainting in buffer: " + ofToString(mySerialConnection.available()) + "\n";
	myfont.drawString(diagnostics, 100,100);
}

I’ve encountered the same issue a while ago. OF wouldn’t receive any serial data from Pi. Like mattc, I had to start a dummy python script that opens and closes serial connection before OF app started, otherwise no serial at all.

Can you share the script, please?

Edited .bashrc
Added line stty raw crtscts -F /dev/ttyAMA0
Now works but I guess that OF need to be fixed against this bug.

1 Like