Raspberry PICO and Message Port ?

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Message
Author
User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Raspberry PICO and Message Port ?

#11 Post by jph »

EDIT - JOE - This info is out of date. AM will with VCPs providing the port is initialised first - AM seems to not be doing it correctly.
See - https://siminnovations.com/forums/viewt ... 314#p48314 - Joe JPH 5 Sept 2022

Hi Mick, at the moment it wont work with messageport unless you add a serial/usb converter to one of the HW serial ports on the pico. You can use a simple FTDI board. You need to make a small change to the SRC files for messageport on the arduino in the simessageport lib. Basically change the serial port in use from serial to serial1 (or whatever). It will then work via the FDI converter.
At the moment AM is looking for a FIXED baudrate of 115200 from the serial port and when using CDC over HID - which is what the PICO does - the baudrate is completely ignored and the comms is as fast as the pc and device can transfer data. AM is not aware of this in Messageport and at the moment, there is no way around that without using the FTDI or similar.
When Corjan gets back I am hoping he will make a version of the MP lib that specifically allows the CDC comms as the possibilities with the pico are amazing on both AM and certainly with MP.

Even at the moment when using the Pico with AM in the non messageport way the comms is via CDC so is incredibly fast. Another reason this is the device to use for AM ;) no nasty serial ports (although they do have their use, just not here :) )

I am sure it will be here at some point.


If you want to play and have an FTDI or similar then find the si_message_port_driver.cpp file in the src directory of the lib in arduino edit it to look like the second version here - first is original - second is modded.

Code: Select all

#include "si_message_port_driver.h"

#include "Arduino.h"

void si_message_port_driver_init() {
	Serial.begin(115200);	
}

void si_message_port_driver_sync(struct SiCircularData* input_buffer, struct SiCircularData* output_buffer) {
	uint8_t byte;
	if ( (Serial.availableForWrite() > 0) && (si_circular_poll(output_buffer, 0, &byte) == SI_OK) ) {
		Serial.write(byte);
	}

	while ( (Serial.available() > 0) && (si_circular_data_free(input_buffer) > 0) ) {
		si_circular_push(input_buffer, Serial.read());
	}
}
modded for Serial1

Code: Select all

#include "si_message_port_driver.h"

#include "Arduino.h"

void si_message_port_driver_init() {
	// Serial.begin(115200);
	Serial1.begin(115200);	// Use Serial1  --  NOTE - we still need to specify our baudrate as 115,200 as we are now using standard serial via the FTDI
}

void si_message_port_driver_sync(struct SiCircularData* input_buffer, struct SiCircularData* output_buffer) {
	uint8_t byte;
	//if ( (Serial.availableForWrite() > 0) && (si_circular_poll(output_buffer, 0, &byte) == SI_OK) ) {
	//	Serial.write(byte);

	// Changed to Serial 1
	if ( (Serial1.availableForWrite() > 0) && (si_circular_poll(output_buffer, 0, &byte) == SI_OK) ) {
		Serial1.write(byte);
	}

	//while ( (Serial.available() > 0) && (si_circular_data_free(input_buffer) > 0) ) {
	//	si_circular_push(input_buffer, Serial.read());
	
	// Changed to Serial 1
	while ( (Serial1.available() > 0) && (si_circular_data_free(input_buffer) > 0) ) {
		si_circular_push(input_buffer, Serial1.read());		
	}
}
Joe
Last edited by jph on Mon Sep 05, 2022 2:26 pm, edited 1 time in total.
Joe. CISSP, MSc.

Mickolodias
Posts: 69
Joined: Mon Sep 13, 2021 3:21 am

Re: Raspberry PICO and Message Port ?

#12 Post by Mickolodias »

Ah I see. All good. I picked up a pico becuase it was cheaper and has more... well... just about everything (except analog ins) than the Leonardo's I use. Just to see what I could do with it :)
I added the Pico as an option back into the MessagePort source and ran it up on a leonardo board - AM recognised it as a Pico :D

I might grab a serial/usb adaper next time I'm electronics shopping given they're pretty cheap (thanks for the code!).
But yeah - would be awesome to take advantage of the speed increase when using MessagePort!

Cheers!
I'm one of 'those' mac guys. (and I have no idea why I can't afford to eat)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Raspberry PICO and Message Port ?

#13 Post by jph »

Yes, it doesn't care what it is called really. The option for PICO naming was there, then partially removed but as you have found you can 'restore it' ;)
It really would be better with a different naming convention anyway - as in 'Raspberry Pi Pico MP (A) to denote messageport. Hopefully that can be changed as well.
If you really want to have a bit of fun then grab one of these. :o :o

Supported in the Arduino IDE and MP compiles ok.

I haven't got one here yet, I will order a couple as they are crazy cheap.

https://eu.mouser.com/ProductDetail/511-NUCLEO-F746ZG
Joe. CISSP, MSc.

Post Reply