How to change the default serial port


#1

Hi
I’m using ulisp on an arduino due . I want to change the serial port to port 2 or 3.
I tried to change lines ‘int address = 0’ on 2 lines in the code , but serial communication stays on the default port.

Does anyone knows what I have to change in the code ?
I’m using latest lisp 2.2

Kind regards ,

Ronny


#2

You should just need to do the following:

In setup() change the line to:

Serial2.begin(9600)

In testescape() change the line to:

if (Serial2.read() == '~') error(PSTR("Escape!"));

Change pserial() to:

void pserial (char c) {
  LastPrint = c;
  if (c == '\n') Serial2.write('\r');
  Serial2.write(c);
}

In gserial() change two lines to:

  while (!Serial2.available());
  char temp = Serial2.read();

Let me know if it works.


#3

Hi

It works perfectly !
Thanks very much :-)

Ronny


#4

Thanks for letting me know!


#5

Hi Johnson

Maybe it would be a good idea to define the serial port in the program , and use #if defined(Serx) … #endif

I did so but I’m unable to upload it to you.
I certainly would like to share it to you , although its straight forward.

Kind regards ,

Ronny


#6

Hi,
how about defining the port as
#define SERIAL_IO Serial2
and use SERIAL_IO instead of ‘SerialN.’ at the places shown by johnsondavies?

Regards,
Kaef