Obsah
Arduino Serial až 2Mb/s (ale 115.200 je lepší)
- ale musely by se přepsat knihovny, aby stíhaly bufferovat https://arduino.stackexchange.com/questions/296/how-high-of-a-baud-rate-can-i-go-without-errors
- At 2 Mb/s, each byte transmission takes 80 CPU cycles
- takže pro 6309 by to bylo asi 10 cyklů - nestíhá interrupty, nejspíš prostě nestíhá nic a budu rád za 115.200 na několika kanálech (aka 2 seriáky+vnitřní sběrnice k Polux3+ nebo tak něco)
divmod10() : a fast replacement for /10 and %10 (unsigned)
https://forum.arduino.cc/t/divmod10-a-fast-replacement-for-10-and-10-unsigned/163586/90
no delay() blink
unsigned long previous_millis, interval = 1000UL; if ( (current_millis - previous_millis) >= interval) { previous_millis = current_millis; // its the time };
Arduino Micro Serial
- Pro výstup na Serial používat if (Serial.availableForWrite()) {Serial.print(F("whatever");};
- Pro monitorování pomocí screen nezapomenout shodit RTS a DTR třeba pomocí close_Serial (close_Serial.c)
#include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> int main(int argc, char *argv[]) { // Check if the correct number of command-line arguments is provided if (argc != 2 ) { fprintf(stderr, "Usage: %s <filename>\n", argv[0]); fprintf(stderr, " %s /dev/ttyACM0 - close USB Serial for Arduino on the port\n", argv[0]); return 1; // Return an error code } int fd; fd = open(argv[1],O_RDWR | O_NOCTTY );//Open Serial Port int RTS_flag; RTS_flag = TIOCM_RTS; int DTR_flag; DTR_flag = TIOCM_DTR; // ioctl(fd,TIOCMBIS,&RTS_flag);//Set RTS pin // ioctl(fd,TIOCMBIS,&DTR_flag);//Set DTR pin // getchar(); ioctl(fd,TIOCMBIC,&RTS_flag);//Clear RTS pin ioctl(fd,TIOCMBIC,&DTR_flag);//Clear DTR pin close(fd); }
nebo close_Serial.py
#!/usr/bin/python -u # vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:ruler:showcmd:lcs=tab\:|- list:tabstop=8:noexpandtab:nosmarttab:softtabstop=0:shiftwidth=0 import serial import sys # Check if the correct number of command-line arguments is provided if not len(sys.argv) in {2,3}: print("Usage: {} <filename> [baudrate]".format(sys.argv[0])) print(" {} /dev/ttyACM0 - close USB Serial for Arduino on the port".format(sys.argv[0])) sys.exit(1) # Exit with a non-zero error code # Get the filename from the command-line argument baudrate=115200 filename = sys.argv[1] if len(sys.argv) > 2: baudrate=sys.argv[2] # Open the serial port ser = serial.Serial(filename, baudrate, xonxoff=False , rtscts=True , dsrdtr=True ) ser.rts=False ser.dtr=False
- A ještě líp, použít picocom -b $(SPEED) --flow n --noreset --hangup --quiet -s cat $(PORT);echo, který tu linku uavře a C-a C-s se tam dá vložit soubor. (A netestovat nic, prostě Serial.print("blabla");)
How to find out all #define used by arduino-cli in compile?
define: ## dump all #define to defines.dump @make |grep g++|grep .ino.cpp.o|sed "s/-o .*/-E -dM -o defines.dump/"|sh @sort defines.dump >defines.d @mv defines.d defines.dump @echo "defines.dump created"