mirror of https://github.com/sebmillet/RF433any
Compare commits
22 Commits
Author | SHA1 | Date |
---|---|---|
Sébastien Millet | e2fb718f5d | |
Sébastien Millet | 0477b30e59 | |
Sébastien Millet | ce6e960758 | |
Sébastien Millet | 373c377b35 | |
sebmillet | e1fab220ae | |
alex-eri | b91028f4ed | |
Sébastien Millet | 68f0d89732 | |
Sébastien Millet | 9071e2d9d2 | |
Sébastien Millet | 9dff51891f | |
sebmillet | 51201c6c53 | |
vojtechj | 2d641530f7 | |
Sébastien Millet | 8f8eded594 | |
Sébastien Millet | 84cb6a6132 | |
Sébastien Millet | faef869755 | |
Sébastien Millet | d84700411b | |
Sébastien Millet | a0e07369fa | |
Sébastien Millet | ef74c2c5c0 | |
sebmillet | b484b6014a | |
ozgunawesome | 9d971025aa | |
Sébastien Millet | e345c00fed | |
Sébastien Millet | bb935c7bd6 | |
Sébastien Millet | f535d56cdb |
24
Makefile
24
Makefile
|
@ -1,10 +1,20 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDUINO_LIBS =
|
||||
ARDMK_DIR = /home/sebastien/.arduino_mk
|
||||
ALL:
|
||||
|
||||
# USER_LIB_PATH = /home/sebastien/travail/cpp/seb/arduino/libraries
|
||||
clean:
|
||||
make -C examples/01_main/ $@
|
||||
make -C examples/02_output-received-code/ $@
|
||||
make -C examples/03_output-signal-timings/ $@
|
||||
make -C examples/04_react_on_code/ $@
|
||||
make -C examples/05_callback/ $@
|
||||
make -C extras/testplan/test/ $@
|
||||
make -C extras/testplan/simul/ $@
|
||||
|
||||
BOARD_TAG = uno
|
||||
MCU = atmega328
|
||||
mrproper:
|
||||
make -C examples/01_main/ $@
|
||||
make -C examples/02_output-received-code/ $@
|
||||
make -C examples/03_output-signal-timings/ $@
|
||||
make -C examples/04_react_on_code/ $@
|
||||
make -C examples/05_callback/ $@
|
||||
make -C extras/testplan/test/ $@
|
||||
make -C extras/testplan/simul/ $@
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
||||
|
|
79
README.md
79
README.md
|
@ -31,15 +31,23 @@ receiver plugged on D2.
|
|||
Usage
|
||||
-----
|
||||
|
||||
See [examples/01_output-received-code/01_output-received-code.ino](examples/01_output-received-code/01_output-received-code.ino)
|
||||
for an example.
|
||||
See [examples/01_main/01_main.ino](examples/01_main/01_main.ino)
|
||||
for an example. This main example will output information in a way that is
|
||||
ready to be used by the RF433recv library, see below why this can be
|
||||
interesting.
|
||||
|
||||
See [examples/02_output-signal-timings/02_output-signal-timings.ino](examples/02_output-signal-timings/02_output-signal-timings.ino)
|
||||
See [examples/02_output-received-code/02_output-received-code.ino](examples/02_output-received-code/02_output-received-code.ino)
|
||||
for another example.
|
||||
|
||||
See [examples/03_react_on_code/03_react_on_code.ino](examples/03_react_on_code/03_react_on_code.ino)
|
||||
See [examples/03_output-signal-timings/03_output-signal-timings.ino](examples/03_output-signal-timings/03_output-signal-timings.ino)
|
||||
for another example, with detailed signal timing information.
|
||||
|
||||
See [examples/04_react_on_code/04_react_on_code.ino](examples/04_react_on_code/04_react_on_code.ino)
|
||||
for an example with code check.
|
||||
|
||||
See [examples/05_callback/05_callback.ino](examples/05_callback/05_callback.ino)
|
||||
for an example with callback functions registered to be called when specific
|
||||
codes are received.
|
||||
|
||||
More details
|
||||
------------
|
||||
|
@ -95,3 +103,66 @@ Bit value depending on convention
|
|||
| Manchester | low short, high short | 0 | 1 |
|
||||
| Manchester | high short, low short | 1 | 0 |
|
||||
|
||||
|
||||
About RF433any versus RF433recv
|
||||
-------------------------------
|
||||
|
||||
RF433recv is found here:
|
||||
[https://github.com/sebmillet/RF433recv](https://github.com/sebmillet/RF433recv)
|
||||
|
||||
- RF433any has no pre-defined idea of the code to analyze (nature of encoding,
|
||||
code timings, number of bits).
|
||||
|
||||
- RF433recv works the other way round: it works with the exact code
|
||||
characteristics.
|
||||
|
||||
**Then what is RF433recv good for?**
|
||||
|
||||
Actually RF433any, while being 'easy and universal', consumes *a lot* of
|
||||
memory, and this can be problematic. RF433recv consumes much less memory,
|
||||
allowing to do something else!
|
||||
|
||||
**How to get the best of the two worlds**
|
||||
|
||||
You can use RF433any to get the exact code characteristics and re-use it with
|
||||
RF433recv library.
|
||||
|
||||
This is the goal of
|
||||
[examples/01_main/01_main.ino](examples/01_main/01_main.ino)
|
||||
|
||||
You can copy-paste the output of `01_main.ino` to call RF433recv library.
|
||||
|
||||
|
||||
About 'false positives'
|
||||
-----------------------
|
||||
|
||||
Since RF433any is struggling to identify a coding sequence from any kind of
|
||||
signal, it is prone to identifying codes from what is noise.
|
||||
|
||||
There are two ways to mitigate it:
|
||||
|
||||
- Use get_nb_bits() (see example `01_main.ino`) and ignore any signal below a
|
||||
certain threshold. Note RF433any has a hard-coded limit of 7 bits of coding.
|
||||
|
||||
- Use strictness of signal analyzis. That is, when creating the Track object,
|
||||
use the second parameter.
|
||||
|
||||
Default Track construction:
|
||||
|
||||
```c++
|
||||
Track track(PIN_RFINPUT);
|
||||
```
|
||||
|
||||
This is equivalent to:
|
||||
|
||||
```c++
|
||||
Track track(PIN_RFINPUT, RAIL_MOOD_LAXIST);
|
||||
```
|
||||
|
||||
If you are tired of fake receptions of actually non-coding signal, you can
|
||||
instead execute:
|
||||
|
||||
```c++
|
||||
Track track(PIN_RFINPUT, RAIL_MOOD_STRICT);
|
||||
```
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Debug.cpp
|
||||
// RF433Debug.cpp
|
||||
|
||||
/*
|
||||
Provides some useful functions to output debug from Arduino on the serial
|
||||
|
@ -24,12 +24,14 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#include "Debug.h"
|
||||
#include "RF433Debug.h"
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
static char buffer[150];
|
||||
static char progmem_reading_buffer[100];
|
||||
static char buffer[120];
|
||||
static char progmem_reading_buffer[91];
|
||||
|
||||
const char *newline = "\n";
|
||||
|
||||
#ifdef __arm__
|
||||
// should use uinstd.h to define sbrk but Due causes a conflict
|
||||
|
@ -38,13 +40,36 @@ extern "C" char* sbrk(int incr);
|
|||
extern char *__brkval;
|
||||
#endif // __arm__
|
||||
|
||||
void dbgfunc(const char* file, long int line, const char* progmem_str) {
|
||||
strcpy_P(progmem_reading_buffer, progmem_str);
|
||||
Serial.print(progmem_reading_buffer);
|
||||
Serial.print("\n");
|
||||
static void fatal(const char* file, long int line, short unsigned len) {
|
||||
Serial.print(newline);
|
||||
Serial.print(file);
|
||||
Serial.print(newline);
|
||||
Serial.print(line);
|
||||
Serial.print(newline);
|
||||
Serial.print(len);
|
||||
Serial.print(newline);
|
||||
Serial.flush();
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
void dbgffunc(const char* file, long int line, const char* progmem_fmt, ...) {
|
||||
void dbgfunc(const char* file, long int line, short unsigned progmem_str_len,
|
||||
const char* progmem_str) {
|
||||
if (progmem_str_len >= sizeof(progmem_reading_buffer)) {
|
||||
fatal(file, line, progmem_str_len);
|
||||
}
|
||||
strcpy_P(progmem_reading_buffer, progmem_str);
|
||||
Serial.print(progmem_reading_buffer);
|
||||
Serial.print(newline);
|
||||
// Not useful normally (sometimes, makes analysis easier in bug fix)
|
||||
// Serial.flush();
|
||||
}
|
||||
|
||||
void dbgffunc(const char* file, long int line, short unsigned progmem_fmt_len,
|
||||
const char* progmem_fmt, ...) {
|
||||
if (progmem_fmt_len >= sizeof(progmem_reading_buffer)) {
|
||||
fatal(file, line, progmem_fmt_len);
|
||||
}
|
||||
strcpy_P(progmem_reading_buffer, progmem_fmt);
|
||||
va_list args;
|
||||
|
||||
|
@ -55,7 +80,9 @@ void dbgffunc(const char* file, long int line, const char* progmem_fmt, ...) {
|
|||
vsnprintf(buffer, sizeof(buffer), progmem_reading_buffer, args);
|
||||
va_end(args);
|
||||
Serial.print(buffer);
|
||||
Serial.print("\n");
|
||||
Serial.print(newline);
|
||||
// Not useful normally (sometimes, makes analysis easier in bug fix)
|
||||
// Serial.flush();
|
||||
}
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -1,4 +1,4 @@
|
|||
// Debug.h
|
||||
// RF433Debug.h
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
@ -18,23 +18,27 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_H
|
||||
#define _DEBUG_H
|
||||
#ifndef _RF433DEBUG_H
|
||||
#define _RF433DEBUG_H
|
||||
|
||||
#define dbg(a) \
|
||||
{ static const char tmp[] PROGMEM = {a}; \
|
||||
dbgfunc(__FILE__, __LINE__, tmp); \
|
||||
constexpr short unsigned l = strlen(a); \
|
||||
dbgfunc(__FILE__, __LINE__, l, tmp); \
|
||||
}
|
||||
|
||||
#define dbgf(a, ...) \
|
||||
{ static const char tmp[] PROGMEM = {a}; \
|
||||
dbgffunc(__FILE__, __LINE__, tmp, __VA_ARGS__); \
|
||||
constexpr short unsigned l = strlen(a); \
|
||||
dbgffunc(__FILE__, __LINE__, l, tmp, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
void dbgfunc(const char* file, long int line, const char *msg);
|
||||
void dbgffunc(const char* file, long int line, const char *format, ...)
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
void dbgfunc(const char* file, long int line, short unsigned msg_len,
|
||||
const char *msg);
|
||||
void dbgffunc(const char* file, long int line, short unsigned format_len,
|
||||
const char *format, ...)
|
||||
__attribute__((format(printf, 4, 5)));
|
||||
|
||||
#endif // _DEBUG_H
|
||||
#endif // _RF433DEBUG_H
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -22,12 +22,12 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#include "Serial.h"
|
||||
#include "RF433Serial.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
SerialLine::SerialLine():head(0),got_a_line(false) { };
|
||||
RF433SerialLine::RF433SerialLine():head(0),got_a_line(false) { };
|
||||
|
||||
void SerialLine::do_events() {
|
||||
void RF433SerialLine::do_events() {
|
||||
if (got_a_line)
|
||||
return;
|
||||
if (!Serial.available())
|
||||
|
@ -39,9 +39,10 @@ void SerialLine::do_events() {
|
|||
if (b == -1)
|
||||
break;
|
||||
buf[head++] = (char)b;
|
||||
} while (head < SERIAL_LINE_BUF_LEN - 1 && b != '\n' && Serial.available());
|
||||
} while (head < RF433SERIAL_LINE_BUF_LEN - 1
|
||||
&& b != '\n' && Serial.available());
|
||||
|
||||
if (head < SERIAL_LINE_BUF_LEN - 1 && b != '\n')
|
||||
if (head < RF433SERIAL_LINE_BUF_LEN - 1 && b != '\n')
|
||||
return;
|
||||
|
||||
buf[head] = '\0';
|
||||
|
@ -57,12 +58,12 @@ void SerialLine::do_events() {
|
|||
got_a_line = true;
|
||||
}
|
||||
|
||||
bool SerialLine::is_line_available() {
|
||||
bool RF433SerialLine::is_line_available() {
|
||||
do_events();
|
||||
return got_a_line;
|
||||
}
|
||||
|
||||
void SerialLine::reset() {
|
||||
void RF433SerialLine::reset() {
|
||||
head = 0;
|
||||
got_a_line = false;
|
||||
}
|
||||
|
@ -74,8 +75,8 @@ void SerialLine::reset() {
|
|||
// (in which case, s is not updated).
|
||||
// The terminating newline character (or 2-character CR-LF sequence) is NOT part
|
||||
// of the string given to the caller.
|
||||
// If the line length is above the buffer size (SERIAL_LINE_BUF_LEN), then it'll
|
||||
// be cut into smaller pieces.
|
||||
// If the line length is above the buffer size (RF433SERIAL_LINE_BUF_LEN), then
|
||||
// it'll be cut into smaller pieces.
|
||||
// Because of the way the received buffer is parsed, and when using CR-LF as
|
||||
// end-of-line marker (default even under Linux), it can result in a empty
|
||||
// string seen after a first string with a length close to the limit.
|
||||
|
@ -84,7 +85,7 @@ void SerialLine::reset() {
|
|||
// - Works fine with Unix new lines (\n), tested
|
||||
// - Supposed to work fine with Windows new lines (\r\n), NOT TESTED
|
||||
// - WON'T WORK WITH MAC-OS NEW LINES (\r)
|
||||
bool SerialLine::get_line(char *s, size_t len) {
|
||||
bool RF433SerialLine::get_line(char *s, size_t len) {
|
||||
do_events();
|
||||
if (!got_a_line)
|
||||
return false;
|
||||
|
@ -95,7 +96,7 @@ bool SerialLine::get_line(char *s, size_t len) {
|
|||
|
||||
// Same as get_line, but with blocking I/O =
|
||||
// Wait without time limit, until a line comes in.
|
||||
void SerialLine::get_line_blocking(char *s, size_t len) {
|
||||
void RF433SerialLine::get_line_blocking(char *s, size_t len) {
|
||||
while (!get_line(s, len))
|
||||
;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// Serial.h
|
||||
// RF433Serial.h
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
@ -18,23 +18,23 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#ifndef _SERIAL_H
|
||||
#define _SERIAL_H
|
||||
#ifndef _RF433SERIAL_H
|
||||
#define _RF433SERIAL_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define SERIAL_LINE_BUF_LEN 19
|
||||
#define RF433SERIAL_LINE_BUF_LEN 19
|
||||
|
||||
class SerialLine {
|
||||
class RF433SerialLine {
|
||||
private:
|
||||
char buf[SERIAL_LINE_BUF_LEN]; // 16-character strings (then CR+LF then
|
||||
// NULL-terminating).
|
||||
char buf[RF433SERIAL_LINE_BUF_LEN]; // 16-character strings (then CR+LF
|
||||
// then NULL-terminating).
|
||||
size_t head;
|
||||
bool got_a_line;
|
||||
void reset();
|
||||
|
||||
public:
|
||||
SerialLine();
|
||||
RF433SerialLine();
|
||||
|
||||
void do_events();
|
||||
bool is_line_available();
|
||||
|
@ -43,6 +43,6 @@ class SerialLine {
|
|||
void split_s_into_func_args(char *s, char **func, char **args) const;
|
||||
};
|
||||
|
||||
#endif // _SERIAL_H
|
||||
#endif // _RF433SERIAL_H
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
162
RF433any.cpp
162
RF433any.cpp
|
@ -141,6 +141,59 @@ static void rf433any_assert_failed(int line) {
|
|||
}
|
||||
|
||||
|
||||
// * ****************** *******************************************************
|
||||
// * compact, uncompact *******************************************************
|
||||
// * ****************** *******************************************************
|
||||
|
||||
// compact() aims to represent 16-bit integers in 8-bit, to the cost of
|
||||
// precision.
|
||||
// The three sets (first one looses 4 bits, middle looses 7, last looses 12)
|
||||
// have been chosen so that smaller durations don't loose too much precision.
|
||||
// The higher the number, the more precision gets lost. This could be seen as
|
||||
// 'the floating point number representation of the (very) poor man' (or,
|
||||
// floating point numbers without... a floating point!)
|
||||
//
|
||||
// Any way, keep in mind Arduino timer produces values always multiple of 4,
|
||||
// that shifts bit-loss by 2.
|
||||
// For example, the first set (that looses 4 bits) actually really looses 2 bits
|
||||
// of precision.
|
||||
duration_t compact(uint16_t u) {
|
||||
#ifdef RF433ANY_DBG_NO_COMPACT_DURATIONS
|
||||
// compact not activated -> compact() is a no-op
|
||||
return u;
|
||||
#else
|
||||
if (u < 2048) {
|
||||
return u >> 4;
|
||||
}
|
||||
if (u < 17408) {
|
||||
return 128 + ((u - 2048) >> 7);
|
||||
}
|
||||
if (u < 46080)
|
||||
return 248 + ((u - 17408) >> 12);
|
||||
return 255;
|
||||
#endif
|
||||
}
|
||||
|
||||
// uncompact() is the opposite of compact(), yes!
|
||||
// Left here in case tests are needed (it is not used in release code).
|
||||
uint16_t uncompact(duration_t b) {
|
||||
#ifdef RF433ANY_DBG_NO_COMPACT_DURATIONS
|
||||
// compact not activated -> uncompact() is a no-op
|
||||
return b;
|
||||
#else
|
||||
uint16_t u = b;
|
||||
if (u < 128) {
|
||||
return u << 4;
|
||||
}
|
||||
u &= 0x7f;
|
||||
if (u < 120) {
|
||||
return (u << 7) + 2048;
|
||||
}
|
||||
return ((u - 120) << 12) + 17408;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// * **** *********************************************************************
|
||||
// * Band *********************************************************************
|
||||
// * **** *********************************************************************
|
||||
|
@ -297,6 +350,8 @@ inline bool Rail::rail_eat(uint16_t d) {
|
|||
|
||||
#ifdef RF433ANY_DBG_TRACE
|
||||
dbg("R> P0");
|
||||
dbgf("R> small = %lu, small * 4 = %lu, big = %lu",
|
||||
small, small << 2, big);
|
||||
#endif
|
||||
|
||||
if ((small << 2) >= big) {
|
||||
|
@ -694,6 +749,8 @@ void Decoder::set_ts(const uint16_t& arg_initseq, const Timings& ts) {
|
|||
tsext.high_short = ts.high_short;
|
||||
tsext.high_long = ts.high_long;
|
||||
tsext.sep = ts.sep;
|
||||
if (arg_initseq && tsext.sep > arg_initseq)
|
||||
tsext.sep = arg_initseq;
|
||||
}
|
||||
|
||||
void Decoder::get_tsext(TimingsExt *p_tsext) const {
|
||||
|
@ -703,11 +760,11 @@ void Decoder::get_tsext(TimingsExt *p_tsext) const {
|
|||
|
||||
void Decoder::take_into_account_first_low_high(const Section *psec,
|
||||
bool is_cont_of_prev_sec) {
|
||||
tsext.last_low = psec->last_low;
|
||||
if (is_cont_of_prev_sec)
|
||||
return;
|
||||
tsext.first_low = psec->first_low;
|
||||
tsext.first_high = psec->first_high;
|
||||
tsext.last_low = psec->last_low;
|
||||
|
||||
Signal e[2];
|
||||
for (short i = 0; i < 2; ++i) {
|
||||
|
@ -1101,10 +1158,10 @@ void DecoderManchester::dbg_decoder(byte disp_level, byte seq) const {
|
|||
// * ***** ********************************************************************
|
||||
|
||||
#ifdef RF433ANY_DBG_SIMULATE
|
||||
SerialLine sl;
|
||||
char buffer[SERIAL_LINE_BUF_LEN];
|
||||
RF433SerialLine sl;
|
||||
char buffer[RF433SERIAL_LINE_BUF_LEN];
|
||||
|
||||
uint16_t sim_timings[SIM_TIMINGS_LEN];
|
||||
duration_t sim_timings[SIM_TIMINGS_LEN];
|
||||
|
||||
uint16_t sim_timings_count = 0;
|
||||
|
||||
|
@ -1131,7 +1188,9 @@ byte Track::pin_number = 99;
|
|||
|
||||
Track::Track(int arg_pin_number, byte mood):
|
||||
r_low(mood),
|
||||
r_high(mood) {
|
||||
r_high(mood),
|
||||
head(nullptr),
|
||||
opt_wait_free_433_before_calling_callbacks(false) {
|
||||
pin_number = arg_pin_number;
|
||||
treset();
|
||||
}
|
||||
|
@ -1141,6 +1200,9 @@ void Track::treset() {
|
|||
rawcode.nb_sections = 0;
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
void Track::ih_handle_interrupt() {
|
||||
static unsigned long last_t = 0;
|
||||
const unsigned long t = micros();
|
||||
|
@ -1152,7 +1214,7 @@ void Track::ih_handle_interrupt() {
|
|||
d = 100;
|
||||
sim_int_count = sim_timings_count + 1;
|
||||
} else {
|
||||
d = sim_timings[sim_int_count++];
|
||||
d = uncompact(sim_timings[sim_int_count++]);
|
||||
}
|
||||
(void)last_t;
|
||||
(void)t;
|
||||
|
@ -1500,12 +1562,12 @@ bool Track::process_interrupt_timing() {
|
|||
|
||||
bool ret;
|
||||
|
||||
cli();
|
||||
noInterrupts();
|
||||
if (IH_read_head != IH_write_head) {
|
||||
IH_timing_t timing = IH_timings[IH_read_head];
|
||||
IH_read_head = (IH_read_head + 1) & IH_MASK;
|
||||
|
||||
sei();
|
||||
interrupts();
|
||||
#ifdef RF433ANY_DBG_TIMINGS
|
||||
unsigned long t0 = micros();
|
||||
#endif
|
||||
|
@ -1527,7 +1589,7 @@ bool Track::process_interrupt_timing() {
|
|||
|
||||
} else {
|
||||
|
||||
sei();
|
||||
interrupts();
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
@ -1563,11 +1625,15 @@ bool Track::do_events() {
|
|||
dbgf("IH_max_pending_timings = %d", ih_get_max_pending_timings());
|
||||
rawcode.debug_rawcode();
|
||||
#endif
|
||||
check_registered_callbacks();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
void Track::ih_handle_interrupt_wait_free() {
|
||||
static unsigned long last_t = 0;
|
||||
|
||||
|
@ -1748,6 +1814,84 @@ Decoder* Track::get_data(uint16_t filter, byte convention) {
|
|||
return pdec0;
|
||||
}
|
||||
|
||||
callback_t* Track::get_tail(const callback_t* h) {
|
||||
const callback_t* pc = h;
|
||||
if (pc) {
|
||||
while (pc->next)
|
||||
pc = pc->next;
|
||||
}
|
||||
return (callback_t*)pc;
|
||||
}
|
||||
|
||||
void Track::setopt_wait_free_433_before_calling_callbacks(const bool val) {
|
||||
opt_wait_free_433_before_calling_callbacks = val;
|
||||
}
|
||||
|
||||
void Track::check_registered_callbacks() {
|
||||
uint32_t t0 = millis();
|
||||
|
||||
bool flag_call_wait_free_433 = opt_wait_free_433_before_calling_callbacks;
|
||||
|
||||
Decoder *pdec0 = get_data(RF433ANY_FD_DECODED | RF433ANY_FD_DEDUP);
|
||||
Decoder *pdec = pdec0;
|
||||
while (pdec) {
|
||||
const BitVector *pdata = pdec->get_pdata();
|
||||
assert(pdata); // Must be the case (RF433ANY_FD_DECODED in the call to
|
||||
// get_data() above).
|
||||
|
||||
for (callback_t *pc = head; pc; pc = pc->next) {
|
||||
if (pc->encoding == RF433ANY_ID_ANY_ENCODING ||
|
||||
pdec->get_id() == pc->encoding) {
|
||||
if (!pdata->cmp(pc->pcode)) {
|
||||
if (!pc->min_delay_between_two_calls ||
|
||||
!pc->last_trigger ||
|
||||
t0 >=
|
||||
pc->last_trigger
|
||||
+ pc->min_delay_between_two_calls
|
||||
) {
|
||||
if (flag_call_wait_free_433) {
|
||||
wait_free_433();
|
||||
flag_call_wait_free_433 = false;
|
||||
}
|
||||
pc->last_trigger = t0;
|
||||
pc->func(pc->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pdec = pdec->get_next();
|
||||
}
|
||||
delete pdec0;
|
||||
}
|
||||
|
||||
void Track::register_callback(byte encoding, const BitVector *pcode, void *data,
|
||||
void (*func)(void *data), uint32_t min_delay_between_two_calls) {
|
||||
|
||||
assert(encoding == RF433ANY_ID_ANY_ENCODING ||
|
||||
encoding == RF433ANY_ID_TRIBIT ||
|
||||
encoding == RF433ANY_ID_TRIBIT_INV ||
|
||||
encoding == RF433ANY_ID_MANCHESTER);
|
||||
assert(pcode);
|
||||
assert(func);
|
||||
|
||||
callback_t *pc = new callback_t;
|
||||
pc->encoding = encoding;
|
||||
pc->pcode = pcode;
|
||||
pc->data = data;
|
||||
pc->func = func;
|
||||
pc->min_delay_between_two_calls = min_delay_between_two_calls;
|
||||
pc->last_trigger = 0;
|
||||
pc->next = nullptr;
|
||||
|
||||
callback_t *tail = get_tail(head);
|
||||
if (tail) {
|
||||
tail->next = pc;
|
||||
} else {
|
||||
head = pc;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RF433ANY_DBG_TIMINGS
|
||||
void Track::dbg_timings() const {
|
||||
for (unsigned int i = 0; i + 1 < ih_dbg_pos; i += 2) {
|
||||
|
|
44
RF433any.h
44
RF433any.h
|
@ -79,13 +79,13 @@
|
|||
#endif
|
||||
|
||||
#ifdef RF433ANY_DBG_SIMULATE
|
||||
#include "Serial.h"
|
||||
#include "RF433Serial.h"
|
||||
#define SIM_TIMINGS_LEN 140
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#include "Debug.h"
|
||||
#include "RF433Debug.h"
|
||||
|
||||
#else
|
||||
|
||||
|
@ -96,6 +96,18 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
// Don't uncomment the below unless you know what you are doing!
|
||||
//#define RF433ANY_DBG_NO_COMPACT_DURATIONS
|
||||
|
||||
#ifdef RF433ANY_DBG_NO_COMPACT_DURATIONS
|
||||
#define duration_t uint16_t
|
||||
#else
|
||||
#define duration_t byte
|
||||
#endif
|
||||
|
||||
duration_t compact(uint16_t u);
|
||||
uint16_t uncompact(duration_t b);
|
||||
|
||||
#define RF433ANY_MAX_DURATION 65535
|
||||
#define RF433ANY_MAX_SEP_DURATION 65535
|
||||
#ifndef RF433ANY_MAX_SECTIONS
|
||||
|
@ -328,6 +340,8 @@ enum class Signal {
|
|||
// always produce a successful result.
|
||||
#define RF433ANY_ID_END 5 // End of enumeration of real decoders
|
||||
|
||||
#define RF433ANY_ID_ANY_ENCODING 99
|
||||
|
||||
class Decoder {
|
||||
private:
|
||||
Decoder *next;
|
||||
|
@ -574,7 +588,7 @@ class DecoderManchester: public Decoder {
|
|||
// * Track ********************************************************************
|
||||
// * ***** ********************************************************************
|
||||
|
||||
#define TRACK_MIN_INITSEQ_DURATION 4000
|
||||
#define TRACK_MIN_INITSEQ_DURATION 2000
|
||||
#define TRACK_MIN_BITS 7
|
||||
|
||||
// IMPORTANT
|
||||
|
@ -596,6 +610,17 @@ struct IH_timing_t {
|
|||
}
|
||||
};
|
||||
|
||||
struct callback_t {
|
||||
byte encoding;
|
||||
const BitVector *pcode;
|
||||
void *data;
|
||||
void (*func)(void *data);
|
||||
uint32_t min_delay_between_two_calls;
|
||||
uint32_t last_trigger;
|
||||
|
||||
callback_t *next;
|
||||
};
|
||||
|
||||
// NOTE - ABOUT STATIC MEMBER VARIABLES AND FUNCTIONS IN THE TRACK CLASS
|
||||
// The class is designed so that one object is useful at a time. This comes
|
||||
// from the fact that we attach interrupt handler to a static method (as is
|
||||
|
@ -608,8 +633,6 @@ struct IH_timing_t {
|
|||
typedef enum {TRK_WAIT, TRK_RECV, TRK_DATA} trk_t;
|
||||
class Track {
|
||||
private:
|
||||
|
||||
|
||||
#ifdef RF433ANY_DBG_TIMINGS
|
||||
static uint16_t ih_dbg_timings[40];
|
||||
static uint16_t ih_dbg_exec[40];
|
||||
|
@ -637,9 +660,14 @@ class Track {
|
|||
|
||||
RawCode rawcode;
|
||||
|
||||
callback_t *head;
|
||||
bool opt_wait_free_433_before_calling_callbacks;
|
||||
|
||||
void reset_border_mgmt();
|
||||
Decoder* get_data_core(byte convention);
|
||||
|
||||
callback_t* get_tail(const callback_t* h);
|
||||
|
||||
public:
|
||||
Track(int arg_pin_number, byte mood = DEFAULT_RAIL_MOOD);
|
||||
|
||||
|
@ -670,6 +698,12 @@ class Track {
|
|||
void wait_free_433();
|
||||
|
||||
Decoder* get_data(uint16_t filter, byte convention = RF433ANY_CONV0);
|
||||
|
||||
void setopt_wait_free_433_before_calling_callbacks(const bool val);
|
||||
void register_callback(byte encoding, const BitVector *pcode,
|
||||
void *data, void (*func)(void *data),
|
||||
uint32_t min_delay_between_two_calls);
|
||||
void check_registered_callbacks();
|
||||
};
|
||||
|
||||
#endif // _RF433ANY_H
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021 Sébastien Millet
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
|
@ -20,10 +20,12 @@
|
|||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.7
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
|
@ -35,12 +37,14 @@ READSPEED=
|
|||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
|
@ -68,6 +72,7 @@ function usage {
|
|||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
|
@ -88,6 +93,7 @@ function usage {
|
|||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -96,7 +102,7 @@ function version {
|
|||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvub:p:s:B:d:crnt: --long help,version,verbose,upload,board:,port:,speed:,fqbn:,builddir:,catusb,stty,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -106,6 +112,7 @@ while true; do
|
|||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
|
@ -117,6 +124,7 @@ while true; do
|
|||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
|
@ -144,12 +152,6 @@ if [ -n "${BOARD}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
#ARDUINODIR=$(LANG='' type -a arduino \
|
||||
# | tail -n 1 \
|
||||
# | sed 's/\S\+\sis\s//')
|
||||
#ARDUINODIR=$(readlink -f "${ARDUINODIR}")
|
||||
#ARDUINODIR=$(dirname "${ARDUINODIR}")
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
|
@ -259,6 +261,7 @@ if [ "${VERBOSE}" == "yes" ]; then
|
|||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
|
@ -269,6 +272,10 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
|
@ -277,35 +284,31 @@ if [ "${COMPILE}" == "yes" ]; then
|
|||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="-libraries ""${TMP_ULIB}"""
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="-prefs=build.extra_flags=-DTESTPLAN=${TESTPLAN}"
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
"${ARDUINODIR}/arduino-builder" \
|
||||
-hardware "${ARDUINODIR}/hardware" \
|
||||
-tools "${ARDUINODIR}/hardware/tools/avr" \
|
||||
-tools "${ARDUINODIR}/tools-builder" \
|
||||
-built-in-libraries "${ARDUINODIR}/libraries" \
|
||||
${OPT_LIB} \
|
||||
-fqbn "${FQBN}" \
|
||||
-build-path "${BUILDDIR}" \
|
||||
${TESTPLAN_OPT} \
|
||||
"${FILE}"
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
"/usr/bin/avrdude" \
|
||||
-q -q -patmega328p -carduino -P"${PORT}" -b"${SPEED}" -D \
|
||||
-Uflash:w:"${BUILDDIR}/${FILEBASENAME}".hex:i
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
|
@ -0,0 +1,100 @@
|
|||
How to install arduino-cli on Ubuntu
|
||||
====================================
|
||||
|
||||
From this URL: https://arduino.github.io/arduino-cli/0.21/installation/
|
||||
|
||||
```
|
||||
# The below installs arduino-cli in ~/bin
|
||||
curl -O -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh
|
||||
sh install.sh
|
||||
|
||||
# the below downloads what it takes to manage arduino:avr boards
|
||||
arduino-cli core install arduino:avr
|
||||
```
|
||||
|
||||
Example for 01_generic.ino (example of RF433recv library):
|
||||
|
||||
```
|
||||
# Compilation
|
||||
|
||||
$ arduino-cli compile -b arduino:avr:nano:cpu=atmega328old --build-path build --libraries /home/sebastien/travail/cpp/seb/arduino/libraries 01_generic.ino
|
||||
|
||||
Le croquis utilise 7950 octets (25%) de l'espace de stockage de programmes. Le maximum est de 30720 octets.
|
||||
Les variables globales utilisent 243 octets (11%) de mémoire dynamique, ce qui laisse 1805 octets pour les variables locales. Le maximum est de 2048 octets.
|
||||
|
||||
Used library Version Path
|
||||
RF433recv 0.3.0 /home/sebastien/travail/cpp/seb/arduino/libraries/RF433recv
|
||||
|
||||
Used platform Version Path
|
||||
arduino:avr 1.8.5 /home/sebastien/.arduino15/packages/arduino/hardware/avr/1.8.5
|
||||
|
||||
# Upload
|
||||
|
||||
$ arduino-cli upload -v -b arduino:avr:nano:cpu=atmega328old --input-dir build -p /dev/ttyUSB0
|
||||
|
||||
"/home/sebastien/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/home/sebastien/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-P/dev/ttyUSB0" -b57600 -D "-Uflash:w:build/01_generic.ino.hex:i"
|
||||
|
||||
avrdude: Version 6.3-20190619
|
||||
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
|
||||
Copyright (c) 2007-2014 Joerg Wunsch
|
||||
|
||||
System wide configuration file is "/home/sebastien/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
|
||||
User configuration file is "/home/sebastien/.avrduderc"
|
||||
User configuration file does not exist or is not a regular file, skipping
|
||||
|
||||
Using Port : /dev/ttyUSB0
|
||||
Using Programmer : arduino
|
||||
Overriding Baud Rate : 57600
|
||||
AVR Part : ATmega328P
|
||||
Chip Erase delay : 9000 us
|
||||
PAGEL : PD7
|
||||
BS2 : PC2
|
||||
RESET disposition : dedicated
|
||||
RETRY pulse : SCK
|
||||
serial program mode : yes
|
||||
parallel program mode : yes
|
||||
Timeout : 200
|
||||
StabDelay : 100
|
||||
CmdexeDelay : 25
|
||||
SyncLoops : 32
|
||||
ByteDelay : 0
|
||||
PollIndex : 3
|
||||
PollValue : 0x53
|
||||
Memory Detail :
|
||||
|
||||
Block Poll Page Polled
|
||||
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
|
||||
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
|
||||
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
|
||||
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
|
||||
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
|
||||
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
|
||||
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
|
||||
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
|
||||
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
|
||||
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
|
||||
|
||||
Programmer Type : Arduino
|
||||
Description : Arduino
|
||||
Hardware Version: 2
|
||||
Firmware Version: 1.16
|
||||
Vtarget : 0.0 V
|
||||
Varef : 0.0 V
|
||||
Oscillator : Off
|
||||
SCK period : 0.1 us
|
||||
|
||||
avrdude: AVR device initialized and ready to accept instructions
|
||||
|
||||
Reading | ################################################## | 100% 0.00s
|
||||
|
||||
avrdude: Device signature = 0x1e950f (probably m328p)
|
||||
avrdude: reading input file "build/01_generic.ino.hex"
|
||||
avrdude: writing flash (7950 bytes):
|
||||
|
||||
Writing | ################################################## | 100% 2.35s
|
||||
|
||||
avrdude: 7950 bytes of flash written
|
||||
|
||||
avrdude done. Thank you.
|
||||
```
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
// 01_main.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Displays the signal shape in a way that is ready to use with the library
|
||||
// RF433recv.
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
||||
`RF433any' is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
`RF433any' is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
//
|
||||
// Schematic: Radio Frequencies RECEIVER plugged on D2.
|
||||
// You can change it by updating PIN_RFINPUT below.
|
||||
// Since the library RF433any uses interruptions, the pin MUST BE either 2 or 3.
|
||||
//
|
||||
|
||||
#include "RF433any.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#define PIN_RFINPUT 2
|
||||
|
||||
// Comment the below macro if you wish to output everything.
|
||||
// As most codes are repeated, this'll likely result in the output of the
|
||||
// same thing multiple times.
|
||||
#define OUTPUT_FIRST_DECODED_ONLY
|
||||
|
||||
char serial_printf_buffer[100];
|
||||
void serial_printf(const char* msg, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
|
||||
// NOTE
|
||||
// Assume Serial has been initialized (Serial.begin(...))
|
||||
void serial_printf(const char* msg, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
|
||||
vsnprintf(serial_printf_buffer, sizeof(serial_printf_buffer), msg, args);
|
||||
va_end(args);
|
||||
Serial.print(serial_printf_buffer);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(PIN_RFINPUT, INPUT);
|
||||
Serial.begin(115200);
|
||||
Serial.print(F("Waiting for signal\n"));
|
||||
}
|
||||
|
||||
Track track(PIN_RFINPUT);
|
||||
|
||||
const char *encoding_names[] = {
|
||||
"RFMOD_TRIBIT", // T
|
||||
"RFMOD_TRIBIT_INVERTED", // N
|
||||
"RFMOD_MANCHESTER", // M
|
||||
"<unmanaged encoding>" // Anything else
|
||||
};
|
||||
|
||||
const char *id_letter_to_encoding_name(char c) {
|
||||
if (c == 'T')
|
||||
return encoding_names[0];
|
||||
else if (c == 'N')
|
||||
return encoding_names[1];
|
||||
else if (c == 'M')
|
||||
return encoding_names[2];
|
||||
|
||||
return encoding_names[3];
|
||||
}
|
||||
|
||||
void output_timings(Decoder *pdec, byte nb_bits) {
|
||||
TimingsExt tsext;
|
||||
if (!pdec)
|
||||
return;
|
||||
pdec->get_tsext(&tsext);
|
||||
|
||||
const char *enc_name = id_letter_to_encoding_name(pdec->get_id_letter());
|
||||
|
||||
serial_printf("\n-----CODE START-----\n");
|
||||
serial_printf("// [WRITE THE DEVICE NAME HERE]\n"
|
||||
"rf.register_Receiver(\n");
|
||||
serial_printf("\t%s, // mod\n", enc_name);
|
||||
serial_printf("\t%u, // initseq\n", tsext.initseq);
|
||||
serial_printf("\t%u, // lo_prefix\n", tsext.first_low);
|
||||
serial_printf("\t%u, // hi_prefix\n", tsext.first_high);
|
||||
serial_printf("\t%u, // first_lo_ign\n", tsext.first_low_ignored);
|
||||
serial_printf("\t%u, // lo_short\n", tsext.low_short);
|
||||
serial_printf("\t%u, // lo_long\n", tsext.low_long);
|
||||
serial_printf("\t%u, // hi_short (0 => take lo_short)\n", tsext.high_short);
|
||||
serial_printf("\t%u, // hi_long (0 => take lo_long)\n", tsext.high_long);
|
||||
serial_printf("\t%u, // lo_last\n", tsext.last_low);
|
||||
serial_printf("\t%u, // sep\n", tsext.sep);
|
||||
serial_printf("\t%u // nb_bits\n", nb_bits);
|
||||
serial_printf(");\n");
|
||||
serial_printf("-----CODE END-----\n\n");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
track.treset();
|
||||
|
||||
while (!track.do_events())
|
||||
delay(1);
|
||||
|
||||
Decoder *pdec0 = track.get_data(RF433ANY_FD_ALL);
|
||||
Decoder *pdec = pdec0;
|
||||
while (pdec) {
|
||||
int nb_bits = pdec->get_nb_bits();
|
||||
BitVector *pdata = pdec->take_away_data();
|
||||
|
||||
if (pdata) {
|
||||
Serial.print("Data: ");
|
||||
char *buf = pdata->to_str();
|
||||
if (buf) {
|
||||
Serial.print(buf);
|
||||
free(buf);
|
||||
}
|
||||
delete pdata;
|
||||
}
|
||||
Serial.print("\n");
|
||||
output_timings(pdec, nb_bits);
|
||||
|
||||
#ifdef OUTPUT_FIRST_DECODED_ONLY
|
||||
pdec = nullptr;
|
||||
delay(1000);
|
||||
#else
|
||||
pdec = pdec->get_next();
|
||||
#endif
|
||||
|
||||
}
|
||||
delete pdec0;
|
||||
}
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021 Sébastien Millet
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
|
@ -20,10 +20,12 @@
|
|||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.7
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
|
@ -35,12 +37,14 @@ READSPEED=
|
|||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
|
@ -68,6 +72,7 @@ function usage {
|
|||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
|
@ -88,6 +93,7 @@ function usage {
|
|||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -96,7 +102,7 @@ function version {
|
|||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvub:p:s:B:d:crnt: --long help,version,verbose,upload,board:,port:,speed:,fqbn:,builddir:,catusb,stty,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -106,6 +112,7 @@ while true; do
|
|||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
|
@ -117,6 +124,7 @@ while true; do
|
|||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
|
@ -144,12 +152,6 @@ if [ -n "${BOARD}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
#ARDUINODIR=$(LANG='' type -a arduino \
|
||||
# | tail -n 1 \
|
||||
# | sed 's/\S\+\sis\s//')
|
||||
#ARDUINODIR=$(readlink -f "${ARDUINODIR}")
|
||||
#ARDUINODIR=$(dirname "${ARDUINODIR}")
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
|
@ -259,6 +261,7 @@ if [ "${VERBOSE}" == "yes" ]; then
|
|||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
|
@ -269,6 +272,10 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
|
@ -277,35 +284,31 @@ if [ "${COMPILE}" == "yes" ]; then
|
|||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="-libraries ""${TMP_ULIB}"""
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="-prefs=build.extra_flags=-DTESTPLAN=${TESTPLAN}"
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
"${ARDUINODIR}/arduino-builder" \
|
||||
-hardware "${ARDUINODIR}/hardware" \
|
||||
-tools "${ARDUINODIR}/hardware/tools/avr" \
|
||||
-tools "${ARDUINODIR}/tools-builder" \
|
||||
-built-in-libraries "${ARDUINODIR}/libraries" \
|
||||
${OPT_LIB} \
|
||||
-fqbn "${FQBN}" \
|
||||
-build-path "${BUILDDIR}" \
|
||||
${TESTPLAN_OPT} \
|
||||
"${FILE}"
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
"/usr/bin/avrdude" \
|
||||
-q -q -patmega328p -carduino -P"${PORT}" -b"${SPEED}" -D \
|
||||
-Uflash:w:"${BUILDDIR}/${FILEBASENAME}".hex:i
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
|
@ -1,10 +0,0 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDUINO_LIBS = RF433any
|
||||
ARDMK_DIR = /home/sebastien/.arduino_mk
|
||||
|
||||
# USER_LIB_PATH = /home/sebastien/travail/cpp/seb/arduino/libraries
|
||||
|
||||
BOARD_TAG = uno
|
||||
MCU = atmega328
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
|
@ -1,4 +1,4 @@
|
|||
// 01_output-received-code.ino
|
||||
// 02_output-received-code.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Simply displays received codes
|
||||
|
@ -54,8 +54,13 @@ void loop() {
|
|||
Serial.print(pdec->get_repeats() + 1);
|
||||
Serial.print("): ");
|
||||
char *buf = pdec->get_pdata()->to_str();
|
||||
Serial.println(buf);
|
||||
free(buf);
|
||||
// DEFENSIVE PROGRAMMING
|
||||
// The option RF433ANY_FD_DECODED above guarantees there's always
|
||||
// something decoded. Test done though, just in case.
|
||||
if (buf) {
|
||||
Serial.println(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
delete pdec0;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021 Sébastien Millet
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
|
@ -20,10 +20,12 @@
|
|||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.7
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
|
@ -35,12 +37,14 @@ READSPEED=
|
|||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
|
@ -68,6 +72,7 @@ function usage {
|
|||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
|
@ -88,6 +93,7 @@ function usage {
|
|||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -96,7 +102,7 @@ function version {
|
|||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvub:p:s:B:d:crnt: --long help,version,verbose,upload,board:,port:,speed:,fqbn:,builddir:,catusb,stty,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -106,6 +112,7 @@ while true; do
|
|||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
|
@ -117,6 +124,7 @@ while true; do
|
|||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
|
@ -144,12 +152,6 @@ if [ -n "${BOARD}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
#ARDUINODIR=$(LANG='' type -a arduino \
|
||||
# | tail -n 1 \
|
||||
# | sed 's/\S\+\sis\s//')
|
||||
#ARDUINODIR=$(readlink -f "${ARDUINODIR}")
|
||||
#ARDUINODIR=$(dirname "${ARDUINODIR}")
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
|
@ -259,6 +261,7 @@ if [ "${VERBOSE}" == "yes" ]; then
|
|||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
|
@ -269,6 +272,10 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
|
@ -277,35 +284,31 @@ if [ "${COMPILE}" == "yes" ]; then
|
|||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="-libraries ""${TMP_ULIB}"""
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="-prefs=build.extra_flags=-DTESTPLAN=${TESTPLAN}"
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
"${ARDUINODIR}/arduino-builder" \
|
||||
-hardware "${ARDUINODIR}/hardware" \
|
||||
-tools "${ARDUINODIR}/hardware/tools/avr" \
|
||||
-tools "${ARDUINODIR}/tools-builder" \
|
||||
-built-in-libraries "${ARDUINODIR}/libraries" \
|
||||
${OPT_LIB} \
|
||||
-fqbn "${FQBN}" \
|
||||
-build-path "${BUILDDIR}" \
|
||||
${TESTPLAN_OPT} \
|
||||
"${FILE}"
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
"/usr/bin/avrdude" \
|
||||
-q -q -patmega328p -carduino -P"${PORT}" -b"${SPEED}" -D \
|
||||
-Uflash:w:"${BUILDDIR}/${FILEBASENAME}".hex:i
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
|
@ -0,0 +1,85 @@
|
|||
// 02_output-received-code.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Simply displays received codes
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
||||
`RF433any' is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
`RF433any' is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
//
|
||||
// Schematic: Radio Frequencies RECEIVER plugged on D2
|
||||
//
|
||||
|
||||
#include "RF433any.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#define PIN_RFINPUT 2
|
||||
|
||||
void setup() {
|
||||
pinMode(PIN_RFINPUT, INPUT);
|
||||
Serial.begin(115200);
|
||||
Serial.print("Waiting for signal\n");
|
||||
}
|
||||
|
||||
Track track(PIN_RFINPUT);
|
||||
|
||||
// NOTE
|
||||
// One could also create a child class, it is cleaner, but I find it overkill
|
||||
char* my_BitVector_to_str(const BitVector *bv) {
|
||||
if (!bv->get_nb_bits())
|
||||
return nullptr;
|
||||
|
||||
byte nb_bytes = bv->get_nb_bytes();
|
||||
|
||||
char *ret = (char*)malloc(nb_bytes * 3);
|
||||
char tmp[3];
|
||||
int j = 0;
|
||||
for (int i = nb_bytes - 1; i >= 0 ; --i) {
|
||||
snprintf(tmp, sizeof(tmp), "%02X", bv->get_nth_byte(i));
|
||||
ret[j] = tmp[0];
|
||||
ret[j + 1] = tmp[1];
|
||||
ret[j + 2] = (i > 0 ? ' ' : '\0');
|
||||
j += 3;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
track.treset();
|
||||
|
||||
while (!track.do_events())
|
||||
delay(1);
|
||||
|
||||
Decoder *pdec0 = track.get_data(
|
||||
RF433ANY_FD_DECODED | RF433ANY_FD_DEDUP | RF433ANY_FD_NO_ERROR
|
||||
);
|
||||
for (Decoder *pdec = pdec0; pdec != nullptr; pdec = pdec->get_next()) {
|
||||
Serial.print("Received ");
|
||||
Serial.print(pdec->get_nb_bits());
|
||||
Serial.print(" bits (x");
|
||||
Serial.print(pdec->get_repeats() + 1);
|
||||
Serial.print("): ");
|
||||
char *buf = my_BitVector_to_str(pdec->get_pdata());
|
||||
Serial.println(buf);
|
||||
free(buf);
|
||||
}
|
||||
delete pdec0;
|
||||
}
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -1,10 +0,0 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDUINO_LIBS = RF433any
|
||||
ARDMK_DIR = /home/sebastien/.arduino_mk
|
||||
|
||||
# USER_LIB_PATH = /home/sebastien/travail/cpp/seb/arduino/libraries
|
||||
|
||||
BOARD_TAG = uno
|
||||
MCU = atmega328
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
|
@ -1,4 +1,4 @@
|
|||
// 02_output-signal-timings.ino
|
||||
// 03_output-signal-timings.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Displays all signals details (incl. non-coding sequences) along with their
|
||||
|
@ -75,7 +75,7 @@ void setup() {
|
|||
free(buf);
|
||||
}
|
||||
|
||||
Track track(PIN_RFINPUT);
|
||||
Track track(PIN_RFINPUT, RAIL_MOOD_STRICT);
|
||||
|
||||
void output_timings(Decoder *pdec) {
|
||||
TimingsExt tsext;
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am
|
||||
# Has an update specific to RF433any library (RF433ANY_TESTPLAN macro used
|
||||
# instead of TESTPLAN).
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021 Sébastien Millet
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
|
@ -22,10 +20,12 @@
|
|||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.7
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
|
@ -37,12 +37,14 @@ READSPEED=
|
|||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
|
@ -70,6 +72,7 @@ function usage {
|
|||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
|
@ -90,6 +93,7 @@ function usage {
|
|||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -98,7 +102,7 @@ function version {
|
|||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvub:p:s:B:d:crnt: --long help,version,verbose,upload,board:,port:,speed:,fqbn:,builddir:,catusb,stty,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
|
@ -108,6 +112,7 @@ while true; do
|
|||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
|
@ -119,6 +124,7 @@ while true; do
|
|||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
|
@ -146,12 +152,6 @@ if [ -n "${BOARD}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
#ARDUINODIR=$(LANG='' type -a arduino \
|
||||
# | tail -n 1 \
|
||||
# | sed 's/\S\+\sis\s//')
|
||||
#ARDUINODIR=$(readlink -f "${ARDUINODIR}")
|
||||
#ARDUINODIR=$(dirname "${ARDUINODIR}")
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
|
@ -261,6 +261,7 @@ if [ "${VERBOSE}" == "yes" ]; then
|
|||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
|
@ -271,6 +272,10 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
|
@ -279,35 +284,31 @@ if [ "${COMPILE}" == "yes" ]; then
|
|||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="-libraries ""${TMP_ULIB}"""
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="-prefs=build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
"${ARDUINODIR}/arduino-builder" \
|
||||
-hardware "${ARDUINODIR}/hardware" \
|
||||
-tools "${ARDUINODIR}/hardware/tools/avr" \
|
||||
-tools "${ARDUINODIR}/tools-builder" \
|
||||
-built-in-libraries "${ARDUINODIR}/libraries" \
|
||||
${OPT_LIB} \
|
||||
-fqbn "${FQBN}" \
|
||||
-build-path "${BUILDDIR}" \
|
||||
${TESTPLAN_OPT} \
|
||||
"${FILE}"
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
"/usr/bin/avrdude" \
|
||||
-q -q -patmega328p -carduino -P"${PORT}" -b"${SPEED}" -D \
|
||||
-Uflash:w:"${BUILDDIR}/${FILEBASENAME}".hex:i
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
|
@ -1,10 +0,0 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDUINO_LIBS = RF433any
|
||||
ARDMK_DIR = /home/sebastien/.arduino_mk
|
||||
|
||||
# USER_LIB_PATH = /home/sebastien/travail/cpp/seb/arduino/libraries
|
||||
|
||||
BOARD_TAG = uno
|
||||
MCU = atmega328
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
|
@ -1,4 +1,4 @@
|
|||
// 03_react_on_code.ino
|
||||
// 04_react_on_code.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Shows how to trigger different actions depending on code received.
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -0,0 +1,346 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
# 2. Upload to Arduino
|
||||
# 3. Read (continually) what is arriving from the USB port the Arduino is
|
||||
# connected to
|
||||
|
||||
# Versions history (as of 1.3)
|
||||
# 1.3 Output from Arduino is recorded in files named with numbers instead of
|
||||
# date-time string.
|
||||
# 1.4 Adds -t (--testplan) option, to set TESTPLAN macro
|
||||
# 1.5 -t (or --testplan) now comes with a value, so as to manage multiple test
|
||||
# plans.
|
||||
# 1.6 Updated to work fine with Arch arduino package instead of the manually
|
||||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
SPEED=
|
||||
FQBN=
|
||||
BUILDDIR=
|
||||
RECORDDIR=out
|
||||
READSPEED=
|
||||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
function finish {
|
||||
if [ "${DISPLAYSEP}" == "yes" ]; then
|
||||
echo "-----END ARDUINO OUTPUT-----" | tee -a "${RECORDFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap finish EXIT
|
||||
|
||||
function usage {
|
||||
echo "Usage:"
|
||||
echo " am [OPTIONS...] FILE"
|
||||
echo "Compile FILE using arduino-builder."
|
||||
echo "Example: am sketch.ino"
|
||||
echo ""
|
||||
echo "ENVIRONMENT VARIABLES"
|
||||
echo " If ARDUINO_USER_LIBS is defined and non empty, then arduino-builder"
|
||||
echo " is called with the supplementary option -libraries followed by"
|
||||
echo " ARDUINO_USER_LIBS' value."
|
||||
echo ""
|
||||
echo "OPTIONS"
|
||||
echo " -h --help Display this help screen"
|
||||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
echo " Normally, speed is infered from device type:"
|
||||
echo " 115200 for Uno, 57600 for Nano"
|
||||
echo " -B --fqbn Board Fully Qualified Name, like 'arduino:avr:uno'"
|
||||
echo " -d --builddir Build directory"
|
||||
echo " -c --catusb Display (continually) what Arduino writes on USB"
|
||||
echo " --stty Tune stty properly for later communication (implied"
|
||||
echo " by --catusb)"
|
||||
echo " -r --recordusb Write USB (continually) to a file (implies -c)"
|
||||
echo " --recordfile Output file if -r option is set"
|
||||
echo " -n --nocompile Don't compile code"
|
||||
echo " --readspeed Read speed of USB. If not specified, this script"
|
||||
echo " will try to infere it from source file. If it"
|
||||
echo " fails, it'll fallback to 9600."
|
||||
echo " This option is useful only if USB is read"
|
||||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function version {
|
||||
echo "am version ${VERSION}"
|
||||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help ) usage; shift ;;
|
||||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
-B | --fqbn ) FQBN="$2"; shift 2 ;;
|
||||
-d | --builddir ) BUILDDIR="$2"; shift 2 ;;
|
||||
-c | --catusb ) CATUSB="yes"; shift ;;
|
||||
-r | --recordusb ) RECORDUSB="yes"; CATUSB="yes"; shift ;;
|
||||
-n | --nocompile ) COMPILE="no"; shift ;;
|
||||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
FILE=${1:-}
|
||||
TRAILINGOPTS=${2:-}
|
||||
|
||||
if [ -n "${TRAILINGOPTS}" ]; then
|
||||
echo "Error: trailing options"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -z "${FILE}" ]; then
|
||||
echo "Error: no input file"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
set +e
|
||||
|
||||
if [ -n "${BOARD}" ]; then
|
||||
if [ "${BOARD}" != "uno" ] && [ "${BOARD}" != "nano" ]; then
|
||||
echo "Error: board '${BOARD}' unknown"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
COUNTNANO=$(compgen -G '/dev/ttyUSB*' | wc -l)
|
||||
|
||||
if [ -z "${BOARD}" ]; then
|
||||
if [ "${COUNTUNO}" -ge 1 ] && [ "${COUNTNANO}" -ge 1 ]; then
|
||||
echo "Error: cannot guess board, found ${COUNTUNO} uno(s), ${COUNTNANO} nano(s)"
|
||||
exit 10
|
||||
fi
|
||||
if [ "${COUNTUNO}" -ge 1 ]; then
|
||||
BOARD=uno
|
||||
elif [ "${COUNTNANO}" -ge 1 ]; then
|
||||
BOARD=nano
|
||||
fi
|
||||
if [ -z "${BOARD}" ]; then
|
||||
echo "Error: cannot guess board, none found";
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ] || [ "${CATUSB}" == "yes" ]; then
|
||||
if [ -z "${PORT}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
COUNT=${COUNTUNO}
|
||||
PORT=$(compgen -G '/dev/ttyACM*')
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
COUNT=${COUNTNANO}
|
||||
PORT=$(compgen -G '/dev/ttyUSB*')
|
||||
else
|
||||
echo "FATAL #001, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if [ "${COUNT}" -ge 2 ]; then
|
||||
echo "Error: cannot guess port, more than 1 board '${BOARD}' found"
|
||||
exit 10
|
||||
fi
|
||||
if [ -z "${PORT}" ]; then
|
||||
echo "Error: cannot guess port, none found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${SPEED}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
SPEED=115200
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
SPEED=57600
|
||||
else
|
||||
echo "FATAL #002, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "${PORT}" ]; then
|
||||
echo "Error: port not found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${FQBN}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
FQBN="arduino:avr:uno"
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
FQBN="arduino:avr:nano:cpu=atmega328old"
|
||||
else
|
||||
echo "FATAL #003, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [[ "${FILE}" == */* ]]; then
|
||||
BUILDDIR=${FILE%/*}
|
||||
BUILDDIR="${BUILDDIR%/}/build"
|
||||
else
|
||||
BUILDDIR=build
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${RECORDUSB}" == "yes" ]; then
|
||||
if [ -z "${RECORDFILE}" ]; then
|
||||
V=${FILE##*/}
|
||||
V=${V%.*}
|
||||
V=${V:-out}
|
||||
PREV=
|
||||
for i in {15..00}; do
|
||||
F="${RECORDDIR}/${V}-$i.txt"
|
||||
if [ -e "${F}" ] && [ -n "${PREV}" ]; then
|
||||
mv "${F}" "${PREV}"
|
||||
fi
|
||||
PREV="${F}"
|
||||
done
|
||||
RECORDFILE="${F}"
|
||||
mkdir -p "${RECORDDIR}"
|
||||
fi
|
||||
else
|
||||
RECORDFILE="/dev/null"
|
||||
fi
|
||||
|
||||
if [ "${VERBOSE}" == "yes" ]; then
|
||||
echo "-- Settings"
|
||||
echo "Arduino dir: ${ARDUINODIR}"
|
||||
echo "Board: ${BOARD}"
|
||||
echo "Port: ${PORT}"
|
||||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
echo "Verbose: ${VERBOSE}"
|
||||
echo "File: ${FILE}"
|
||||
echo "Build dir: ${BUILDDIR}"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
mkdir -p "${BUILDDIR}"
|
||||
|
||||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
||||
if [ -z "${READSPEED}" ]; then
|
||||
TFILE=$(mktemp)
|
||||
gcc -fpreprocessed -dD -x c++ -E "${FILE}" > "${TFILE}"
|
||||
for sp in 9600 19200 28800 38400 57600 115200; do
|
||||
if grep ${sp} "${TFILE}" > /dev/null; then
|
||||
READSPEED=${sp}
|
||||
fi
|
||||
done
|
||||
READSPEED=${READSPEED:-9600}
|
||||
rm "${TFILE}"
|
||||
fi
|
||||
|
||||
stty -F "${PORT}" -hupcl -echo "${READSPEED}"
|
||||
echo "-- usb setup with speed ${READSPEED}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ]; then
|
||||
echo "-- Read usb (Ctrl-C to quit)"
|
||||
DISPLAYSEP=yes
|
||||
{
|
||||
echo "speed=${READSPEED}"
|
||||
echo "fqbn=${FQBN}"
|
||||
echo "port=${PORT}"
|
||||
echo "file=${FILE}"
|
||||
echo "filedate=$(date +"%Y-%m-%dT%H:%M:%SZ" -d @$(stat -c '%Y' "${FILE}"))"
|
||||
echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
echo ""
|
||||
echo "-----BEGIN ARDUINO OUTPUT-----"
|
||||
} | tee "${RECORDFILE}"
|
||||
tee -a "${RECORDFILE}" < "${PORT}"
|
||||
fi
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// 05_callback.ino
|
||||
|
||||
// Example sketch that comes along with RF433any library
|
||||
// Shows how to trigger different actions depending on code received, by
|
||||
// registering callback function.
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
||||
`RF433any' is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
`RF433any' is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
//
|
||||
// Schematic: Radio Frequencies RECEIVER plugged on D2
|
||||
//
|
||||
|
||||
#include "RF433any.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#define PIN_RFINPUT 2
|
||||
|
||||
Track track(PIN_RFINPUT);
|
||||
|
||||
byte dummy;
|
||||
|
||||
void on_call_anycode(void *data) {
|
||||
}
|
||||
|
||||
void on_call(void *data) {
|
||||
byte n = (byte *)data - &dummy;
|
||||
Serial.print("Received code number ");
|
||||
Serial.print(n);
|
||||
Serial.print("\n");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(PIN_RFINPUT, INPUT);
|
||||
Serial.begin(115200);
|
||||
track.setopt_wait_free_433_before_calling_callbacks(true);
|
||||
track.register_callback(RF433ANY_ID_TRIBIT_INV,
|
||||
new BitVector(12, 2, 0x04, 0xf0),
|
||||
(void *)(&dummy + 1), on_call, 2000);
|
||||
track.register_callback(RF433ANY_ID_TRIBIT_INV,
|
||||
new BitVector(12, 2, 0x04, 0xf1),
|
||||
(void *)(&dummy + 2), on_call, 2000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
track.treset();
|
||||
while (!track.do_events())
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -0,0 +1,346 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
# 2. Upload to Arduino
|
||||
# 3. Read (continually) what is arriving from the USB port the Arduino is
|
||||
# connected to
|
||||
|
||||
# Versions history (as of 1.3)
|
||||
# 1.3 Output from Arduino is recorded in files named with numbers instead of
|
||||
# date-time string.
|
||||
# 1.4 Adds -t (--testplan) option, to set TESTPLAN macro
|
||||
# 1.5 -t (or --testplan) now comes with a value, so as to manage multiple test
|
||||
# plans.
|
||||
# 1.6 Updated to work fine with Arch arduino package instead of the manually
|
||||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
SPEED=
|
||||
FQBN=
|
||||
BUILDDIR=
|
||||
RECORDDIR=out
|
||||
READSPEED=
|
||||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
function finish {
|
||||
if [ "${DISPLAYSEP}" == "yes" ]; then
|
||||
echo "-----END ARDUINO OUTPUT-----" | tee -a "${RECORDFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap finish EXIT
|
||||
|
||||
function usage {
|
||||
echo "Usage:"
|
||||
echo " am [OPTIONS...] FILE"
|
||||
echo "Compile FILE using arduino-builder."
|
||||
echo "Example: am sketch.ino"
|
||||
echo ""
|
||||
echo "ENVIRONMENT VARIABLES"
|
||||
echo " If ARDUINO_USER_LIBS is defined and non empty, then arduino-builder"
|
||||
echo " is called with the supplementary option -libraries followed by"
|
||||
echo " ARDUINO_USER_LIBS' value."
|
||||
echo ""
|
||||
echo "OPTIONS"
|
||||
echo " -h --help Display this help screen"
|
||||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
echo " Normally, speed is infered from device type:"
|
||||
echo " 115200 for Uno, 57600 for Nano"
|
||||
echo " -B --fqbn Board Fully Qualified Name, like 'arduino:avr:uno'"
|
||||
echo " -d --builddir Build directory"
|
||||
echo " -c --catusb Display (continually) what Arduino writes on USB"
|
||||
echo " --stty Tune stty properly for later communication (implied"
|
||||
echo " by --catusb)"
|
||||
echo " -r --recordusb Write USB (continually) to a file (implies -c)"
|
||||
echo " --recordfile Output file if -r option is set"
|
||||
echo " -n --nocompile Don't compile code"
|
||||
echo " --readspeed Read speed of USB. If not specified, this script"
|
||||
echo " will try to infere it from source file. If it"
|
||||
echo " fails, it'll fallback to 9600."
|
||||
echo " This option is useful only if USB is read"
|
||||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function version {
|
||||
echo "am version ${VERSION}"
|
||||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help ) usage; shift ;;
|
||||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
-B | --fqbn ) FQBN="$2"; shift 2 ;;
|
||||
-d | --builddir ) BUILDDIR="$2"; shift 2 ;;
|
||||
-c | --catusb ) CATUSB="yes"; shift ;;
|
||||
-r | --recordusb ) RECORDUSB="yes"; CATUSB="yes"; shift ;;
|
||||
-n | --nocompile ) COMPILE="no"; shift ;;
|
||||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
FILE=${1:-}
|
||||
TRAILINGOPTS=${2:-}
|
||||
|
||||
if [ -n "${TRAILINGOPTS}" ]; then
|
||||
echo "Error: trailing options"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -z "${FILE}" ]; then
|
||||
echo "Error: no input file"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
set +e
|
||||
|
||||
if [ -n "${BOARD}" ]; then
|
||||
if [ "${BOARD}" != "uno" ] && [ "${BOARD}" != "nano" ]; then
|
||||
echo "Error: board '${BOARD}' unknown"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
COUNTNANO=$(compgen -G '/dev/ttyUSB*' | wc -l)
|
||||
|
||||
if [ -z "${BOARD}" ]; then
|
||||
if [ "${COUNTUNO}" -ge 1 ] && [ "${COUNTNANO}" -ge 1 ]; then
|
||||
echo "Error: cannot guess board, found ${COUNTUNO} uno(s), ${COUNTNANO} nano(s)"
|
||||
exit 10
|
||||
fi
|
||||
if [ "${COUNTUNO}" -ge 1 ]; then
|
||||
BOARD=uno
|
||||
elif [ "${COUNTNANO}" -ge 1 ]; then
|
||||
BOARD=nano
|
||||
fi
|
||||
if [ -z "${BOARD}" ]; then
|
||||
echo "Error: cannot guess board, none found";
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ] || [ "${CATUSB}" == "yes" ]; then
|
||||
if [ -z "${PORT}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
COUNT=${COUNTUNO}
|
||||
PORT=$(compgen -G '/dev/ttyACM*')
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
COUNT=${COUNTNANO}
|
||||
PORT=$(compgen -G '/dev/ttyUSB*')
|
||||
else
|
||||
echo "FATAL #001, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if [ "${COUNT}" -ge 2 ]; then
|
||||
echo "Error: cannot guess port, more than 1 board '${BOARD}' found"
|
||||
exit 10
|
||||
fi
|
||||
if [ -z "${PORT}" ]; then
|
||||
echo "Error: cannot guess port, none found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${SPEED}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
SPEED=115200
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
SPEED=57600
|
||||
else
|
||||
echo "FATAL #002, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "${PORT}" ]; then
|
||||
echo "Error: port not found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${FQBN}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
FQBN="arduino:avr:uno"
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
FQBN="arduino:avr:nano:cpu=atmega328old"
|
||||
else
|
||||
echo "FATAL #003, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [[ "${FILE}" == */* ]]; then
|
||||
BUILDDIR=${FILE%/*}
|
||||
BUILDDIR="${BUILDDIR%/}/build"
|
||||
else
|
||||
BUILDDIR=build
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${RECORDUSB}" == "yes" ]; then
|
||||
if [ -z "${RECORDFILE}" ]; then
|
||||
V=${FILE##*/}
|
||||
V=${V%.*}
|
||||
V=${V:-out}
|
||||
PREV=
|
||||
for i in {15..00}; do
|
||||
F="${RECORDDIR}/${V}-$i.txt"
|
||||
if [ -e "${F}" ] && [ -n "${PREV}" ]; then
|
||||
mv "${F}" "${PREV}"
|
||||
fi
|
||||
PREV="${F}"
|
||||
done
|
||||
RECORDFILE="${F}"
|
||||
mkdir -p "${RECORDDIR}"
|
||||
fi
|
||||
else
|
||||
RECORDFILE="/dev/null"
|
||||
fi
|
||||
|
||||
if [ "${VERBOSE}" == "yes" ]; then
|
||||
echo "-- Settings"
|
||||
echo "Arduino dir: ${ARDUINODIR}"
|
||||
echo "Board: ${BOARD}"
|
||||
echo "Port: ${PORT}"
|
||||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
echo "Verbose: ${VERBOSE}"
|
||||
echo "File: ${FILE}"
|
||||
echo "Build dir: ${BUILDDIR}"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
mkdir -p "${BUILDDIR}"
|
||||
|
||||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
||||
if [ -z "${READSPEED}" ]; then
|
||||
TFILE=$(mktemp)
|
||||
gcc -fpreprocessed -dD -x c++ -E "${FILE}" > "${TFILE}"
|
||||
for sp in 9600 19200 28800 38400 57600 115200; do
|
||||
if grep ${sp} "${TFILE}" > /dev/null; then
|
||||
READSPEED=${sp}
|
||||
fi
|
||||
done
|
||||
READSPEED=${READSPEED:-9600}
|
||||
rm "${TFILE}"
|
||||
fi
|
||||
|
||||
stty -F "${PORT}" -hupcl -echo "${READSPEED}"
|
||||
echo "-- usb setup with speed ${READSPEED}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ]; then
|
||||
echo "-- Read usb (Ctrl-C to quit)"
|
||||
DISPLAYSEP=yes
|
||||
{
|
||||
echo "speed=${READSPEED}"
|
||||
echo "fqbn=${FQBN}"
|
||||
echo "port=${PORT}"
|
||||
echo "file=${FILE}"
|
||||
echo "filedate=$(date +"%Y-%m-%dT%H:%M:%SZ" -d @$(stat -c '%Y' "${FILE}"))"
|
||||
echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
echo ""
|
||||
echo "-----BEGIN ARDUINO OUTPUT-----"
|
||||
} | tee "${RECORDFILE}"
|
||||
tee -a "${RECORDFILE}" < "${PORT}"
|
||||
fi
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt =
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -1,2 +1,2 @@
|
|||
[0] Received 9 bits: 01 6e
|
||||
T=TRI, E=0, I=9000, S=572, L=1256, P=7020, Y=0, Z=522
|
||||
T=TRI, E=0, I=8960, S=568, L=1256, P=6912, Y=0, Z=512
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
[0] Received 9 bits: 01 6e
|
||||
T=TRI, E=0, I=9000, S=572, L=1256, P=7020, Y=0, Z=528
|
||||
T=TRI, E=0, I=8960, S=568, L=1256, P=6912, Y=0, Z=512
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[0] Unknown encoding: 18 signal bits
|
||||
Signal: LS:SL:LS:LS:SL:LS:LS:LS:LL:SP
|
||||
T=UNK, E=0, I=9000, S=572, L=1256, P=7020, Y=0, Z=522
|
||||
T=UNK, E=0, I=8960, S=568, L=1256, P=6912, Y=0, Z=512
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[0] Unknown encoding: 18 signal bits
|
||||
Signal: LS:SL:LS:LS:SL:LS:LS:LS:LL:SP
|
||||
T=UNK, E=0, I=9000, S=572, L=1256, P=7020, Y=0, Z=1232
|
||||
T=UNK, E=0, I=8960, S=568, L=1256, P=6912, Y=0, Z=512
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 32 bits: b5 35 6d 00
|
||||
T=TRI, E=0, I=6908, S=598, L=1224, P=7036, Y=0, Z=560
|
||||
T=TRI, E=0, I=6784, S=592, L=1216, P=6784, Y=0, Z=560
|
||||
[1] Received 32 bits: b5 35 6d 00
|
||||
T=TRI, E=0, I=0, S=598, L=1224, P=6984, Y=0, Z=408
|
||||
T=TRI, E=0, I=0, S=592, L=1216, P=6912, Y=0, Z=400
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 32 bits: b5 35 6d 00
|
||||
T=TRI, E=0, I=6908, S=598, L=1224, P=7036, Y=0, Z=572
|
||||
T=TRI, E=0, I=6784, S=592, L=1216, P=6784, Y=0, Z=560
|
||||
[1] Received 32 bits: b5 35 6d 00
|
||||
T=TRI, E=0, I=0, S=598, L=1224, P=6984, Y=0, Z=544
|
||||
T=TRI, E=0, I=0, S=592, L=1216, P=6912, Y=0, Z=400
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=5436, S=1180, L=2270, P=6724, Y=0, Z=1112
|
||||
T=MAN, E=0, I=5376, S=1176, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=0, S=1180, L=2270, P=6740, Y=0, Z=1088
|
||||
T=MAN, E=0, I=0, S=1176, L=2240, P=6656, Y=0, Z=1088
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=5436, S=1180, L=2270, P=6724, Y=0, Z=1180
|
||||
T=MAN, E=0, I=5376, S=1176, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=0, S=1180, L=2270, P=6740, Y=0, Z=1120
|
||||
T=MAN, E=0, I=0, S=1176, L=2240, P=6656, Y=0, Z=1088
|
||||
[2] Received 9 bits: 00 fd
|
||||
T=MAN, E=0, I=0, S=1180, L=2270, P=0, Y=0, Z=1088
|
||||
T=MAN, E=0, I=0, S=1176, L=2240, P=0, Y=0, Z=1088
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 32 bits: 8e dc 56 7f
|
||||
T=MAN, E=0, I=5568, S=1154, L=2314, P=5576, Y=0, Z=1100
|
||||
T=MAN, E=0, I=5504, S=1144, L=2240, P=5504, Y=0, Z=1088
|
||||
[1] Received 32 bits: 8e dc 56 7f
|
||||
T=MAN, E=0, I=0, S=1154, L=2314, P=5584, Y=0, Z=1080
|
||||
T=MAN, E=0, I=0, S=1144, L=2240, P=5504, Y=0, Z=1072
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 32 bits: 8e dc 56 7f
|
||||
T=MAN, E=0, I=5568, S=1154, L=2314, P=5576, Y=0, Z=2260
|
||||
T=MAN, E=0, I=5504, S=1144, L=2240, P=5504, Y=0, Z=1088
|
||||
[1] Received 32 bits: 8e dc 56 7f
|
||||
T=MAN, E=0, I=0, S=1154, L=2314, P=5584, Y=0, Z=2248
|
||||
T=MAN, E=0, I=0, S=1144, L=2240, P=5504, Y=0, Z=1072
|
||||
[2] Received 11 bits: 04 76
|
||||
T=MAN, E=0, I=0, S=1154, L=2314, P=0, Y=0, Z=2244
|
||||
T=MAN, E=0, I=0, S=1144, L=2240, P=0, Y=0, Z=2176
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 32 bits: fe dc 56 78
|
||||
T=MAN, E=0, I=5468, S=1154, L=2310, P=6716, Y=0, Z=1104
|
||||
T=MAN, E=0, I=5376, S=1152, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Received 32 bits: fe dc 56 78
|
||||
T=MAN, E=0, I=0, S=1154, L=2310, P=6732, Y=0, Z=1088
|
||||
T=MAN, E=0, I=0, S=1152, L=2240, P=6656, Y=0, Z=1088
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 32 bits: fe dc 56 78
|
||||
T=MAN, E=0, I=5468, S=1154, L=2310, P=6716, Y=0, Z=1180
|
||||
T=MAN, E=0, I=5376, S=1152, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Received 32 bits: fe dc 56 78
|
||||
T=MAN, E=0, I=0, S=1154, L=2310, P=6732, Y=0, Z=1116
|
||||
T=MAN, E=0, I=0, S=1152, L=2240, P=6656, Y=0, Z=1088
|
||||
[2] Received 9 bits: 01 fd
|
||||
T=MAN, E=0, I=0, S=1154, L=2310, P=0, Y=0, Z=1096
|
||||
T=MAN, E=0, I=0, S=1152, L=2240, P=0, Y=0, Z=1088
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[0] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=5436, S=1180, L=2270, P=6724, Y=0, Z=1112
|
||||
T=MAN, E=0, I=5376, S=1176, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Unknown encoding: 50 signal bits
|
||||
Signal: SS:SL:SS:SS:SS:SS:SS:LL:SS:LL:SS:SS:LS:SS:SL:LL:SL:SS:LS:SL:SS:SS:SS:LS:SS:SP
|
||||
T=UNK, E=0, I=0, S=1180, L=2270, P=6740, Y=0, Z=1088
|
||||
T=UNK, E=0, I=0, S=1176, L=2240, P=6656, Y=0, Z=1088
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 32 bits: 7e dc 56 78
|
||||
T=MAN, E=0, I=5436, S=1180, L=2270, P=6724, Y=0, Z=1180
|
||||
T=MAN, E=0, I=5376, S=1176, L=2240, P=5376, Y=0, Z=1104
|
||||
[1] Received 27 bits(!): 03 f6 e2 a3
|
||||
T=MAN, E=4, I=0, S=1180, L=2270, P=6740, Y=0, Z=1120
|
||||
T=MAN, E=4, I=0, S=1176, L=2240, P=6656, Y=0, Z=1088
|
||||
[2] Received 9 bits: 00 fd
|
||||
T=MAN, E=0, I=0, S=1180, L=2270, P=0, Y=0, Z=1088
|
||||
T=MAN, E=0, I=0, S=1176, L=2240, P=0, Y=0, Z=1088
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=344
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14924, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3740, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 29 3d 1c 2f 08 98 cf
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=3000, Y=0, Z=316
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=2944, Y=0, Z=688
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14924, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3740, Y=0, Z=324
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=320
|
||||
[1] Received 55 bits: 29 3d 1c 2f 08 98 cf
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=3000, Y=0, Z=336
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=2944, Y=0, Z=688
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 33 bits: 01 42 3c 68 c0
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=15284, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=15232, Y=0, Z=320
|
||||
[2] Sync 11
|
||||
T=SYN, E=0, I=0, S=356, L=734, P=3740, Y=0, Z=336
|
||||
T=SYN, E=0, I=0, S=344, L=728, P=3712, Y=0, Z=336
|
||||
[3] Received 9 bits: 01 42
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=3740, Y=0, Z=336
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=3712, Y=0, Z=336
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=344
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 33 bits: 01 42 3c 68 c0
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=15284, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=15232, Y=0, Z=320
|
||||
[2] Sync 11
|
||||
T=SYN, E=0, I=0, S=356, L=734, P=3740, Y=0, Z=340
|
||||
T=SYN, E=0, I=0, S=344, L=728, P=3712, Y=0, Z=336
|
||||
[3] Received 9 bits: 01 42
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=0, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=0, Y=0, Z=352
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 33 bits: 01 42 3c 68 c0
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=15284, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=15232, Y=0, Z=320
|
||||
[2] Sync 11
|
||||
T=SYN, E=0, I=0, S=356, L=734, P=3740, Y=0, Z=336
|
||||
T=SYN, E=0, I=0, S=344, L=728, P=3712, Y=0, Z=336
|
||||
[3] Received 10 bits: 02 84
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=15284, Y=0, Z=328
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=15232, Y=0, Z=320
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=344
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 33 bits: 01 42 3c 68 c0
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=15284, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=15232, Y=0, Z=320
|
||||
[2] Sync 11
|
||||
T=SYN, E=0, I=0, S=356, L=734, P=3740, Y=0, Z=340
|
||||
T=SYN, E=0, I=0, S=344, L=728, P=3712, Y=0, Z=336
|
||||
[3] Received 9 bits: 01 42
|
||||
T=TRI, E=0, I=0, S=356, L=734, P=0, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=344, L=728, P=0, Y=0, Z=352
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Unknown encoding: 66 signal bits
|
||||
Signal: LS:SL:LS:SL:SL:SL:SL:LS:SL:SL:SL:LS:LS:LS:LS:SL:SL:SL:LS:LS:SL:LS:SL:SL:SL:LS:LS:SL:SL:SL:SL:SL:LL
|
||||
T=UNK, E=0, I=0, S=356, L=734, P=0, Y=0, Z=717
|
||||
T=UNK, E=0, I=0, S=344, L=728, P=0, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=344
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Received 48 bits(!): a1 1e 34 60 22 63
|
||||
T=TRI, E=1, I=0, S=356, L=734, P=0, Y=0, Z=356
|
||||
T=TRI, E=1, I=0, S=344, L=728, P=0, Y=0, Z=704
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Unknown encoding: 48 signal bits
|
||||
Signal: LS:SL:SS:SL:SL:LS:SL:SL:SL:SL:LS:LS:SL:SL:SL:LS:LS:SL:SL:LS:LS:SL:LS:LS:SP
|
||||
T=UNK, E=0, I=0, S=356, L=736, P=15284, Y=0, Z=328
|
||||
T=UNK, E=0, I=0, S=344, L=736, P=15232, Y=0, Z=320
|
||||
[2] Sync 8
|
||||
T=SYN, E=0, I=0, S=356, L=736, P=3740, Y=0, Z=336
|
||||
T=SYN, E=0, I=0, S=344, L=736, P=3712, Y=0, Z=336
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=348, L(lo)=348, S(hi)=364, L(hi)=364, P=3724, Y=0, Z=344
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=352, L(hi)=352, P=3712, Y=0, Z=336
|
||||
[1] Unknown encoding: 48 signal bits
|
||||
Signal: LS:SL:SS:SL:SL:LS:SL:SL:SL:SL:LS:LS:SL:SL:SL:LS:LS:SL:SL:LS:LS:SL:LS:LS:SP
|
||||
T=UNK, E=0, I=0, S=356, L=736, P=15284, Y=0, Z=340
|
||||
T=UNK, E=0, I=0, S=344, L=736, P=15232, Y=0, Z=320
|
||||
[2] Sync 8
|
||||
T=SYN, E=0, I=0, S=356, L=736, P=3740, Y=0, Z=336
|
||||
T=SYN, E=0, I=0, S=344, L=736, P=3712, Y=0, Z=336
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
0, 5652
|
||||
1180, 300
|
||||
1180, 320
|
||||
440, 924
|
||||
1164, 236
|
||||
1136, 264
|
||||
1156, 244
|
||||
1164, 336
|
||||
1136, 294
|
||||
1156, 294
|
||||
408, 952
|
||||
416, 948
|
||||
1144, 256
|
||||
1144, 266
|
||||
400, 964
|
||||
1124, 276
|
||||
400, 968
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=5652, S=338, L=1044, P=10664, Y=0, Z=364
|
||||
T=TRI, E=0, I=5632, S=384, L=1032, P=5632, Y=0, Z=352
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=10688, Y=0, Z=324
|
||||
T=TRI, E=0, I=0, S=384, L=1032, P=10624, Y=0, Z=320
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=5652, S=338, L=1044, P=10664, Y=0, Z=400
|
||||
T=TRI, E=0, I=5632, S=384, L=1032, P=5632, Y=0, Z=352
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=10688, Y=0, Z=364
|
||||
T=TRI, E=0, I=0, S=384, L=1032, P=10624, Y=0, Z=320
|
||||
[2] Received 17 bits: 01 72 9a
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=0, Y=0, Z=328
|
||||
T=TRI, E=0, I=0, S=384, L=1032, P=0, Y=0, Z=320
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=10680, S=336, L=1036, P=10700, Y=0, Z=328
|
||||
T=TRI, E=0, I=10624, S=336, L=1032, P=10624, Y=0, Z=320
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=336, L=1036, P=10708, Y=0, Z=316
|
||||
T=TRI, E=0, I=0, S=336, L=1032, P=10624, Y=0, Z=304
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=10680, S=336, L=1036, P=10700, Y=0, Z=348
|
||||
T=TRI, E=0, I=10624, S=336, L=1032, P=10624, Y=0, Z=320
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=336, L=1036, P=10708, Y=0, Z=332
|
||||
T=TRI, E=0, I=0, S=336, L=1032, P=10624, Y=0, Z=304
|
||||
[2] Received 17 bits: 01 72 9a
|
||||
T=TRI, E=0, I=0, S=336, L=1036, P=0, Y=0, Z=312
|
||||
T=TRI, E=0, I=0, S=336, L=1032, P=0, Y=0, Z=304
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
0, 5652
|
||||
1180, 300
|
||||
440, 924
|
||||
1164, 236
|
||||
1136, 264
|
||||
1156, 244
|
||||
1164, 300
|
||||
1136, 284
|
||||
1156, 294
|
||||
408, 952
|
||||
416, 948
|
||||
1144, 256
|
||||
1144, 276
|
||||
400, 964
|
||||
400, 276
|
||||
400, 968
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[0] Unknown encoding: 48 signal bits
|
||||
Signal: LS:SL:LS:LS:LS:SL:SL:LS:SL:SS:SL:SL:LS:LS:SL:LS:SL:SL:LS:SL:SL:LS:SL:SL:SP
|
||||
T=UNK, E=0, I=5652, S=338, L=1044, P=10664, Y=0, Z=364
|
||||
T=UNK, E=0, I=5632, S=360, L=1032, P=5632, Y=0, Z=352
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=10688, Y=0, Z=324
|
||||
T=TRI, E=0, I=0, S=360, L=1032, P=10624, Y=0, Z=320
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[0] Received 23 bits(!): 5c 8d 24
|
||||
T=TRI, E=1, I=5652, S=338, L=1044, P=10664, Y=0, Z=400
|
||||
T=TRI, E=1, I=5632, S=360, L=1032, P=5632, Y=0, Z=352
|
||||
[1] Received 24 bits: b9 4d 24
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=10688, Y=0, Z=364
|
||||
T=TRI, E=0, I=0, S=360, L=1032, P=10624, Y=0, Z=320
|
||||
[2] Received 17 bits: 01 72 9a
|
||||
T=TRI, E=0, I=0, S=338, L=1044, P=0, Y=0, Z=328
|
||||
T=TRI, E=0, I=0, S=360, L=1032, P=0, Y=0, Z=320
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=23908, S=650, L=1348, P=23912, Y=650, Z=656
|
||||
T=TRN, E=0, I=21504, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=664
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[2] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23956, Y=650, Z=628
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=624
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=656
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=23908, S=650, L=1348, P=23912, Y=650, Z=700
|
||||
T=TRN, E=0, I=21504, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=664
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[2] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23956, Y=650, Z=672
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=624
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=636
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=23908, S=666, L=1356, P=23956, Y=666, Z=636
|
||||
T=TRN, E=0, I=21504, S=664, L=1352, P=21504, Y=664, Z=624
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23964, Y=666, Z=636
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=624
|
||||
[2] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23952, Y=666, Z=640
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=640
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23952, Y=666, Z=648
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=640
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[0] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=23908, S=666, L=1356, P=23956, Y=666, Z=708
|
||||
T=TRN, E=0, I=21504, S=664, L=1352, P=21504, Y=664, Z=624
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23964, Y=666, Z=632
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=624
|
||||
[2] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23952, Y=666, Z=636
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=640
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=666, L=1356, P=23952, Y=666, Z=656
|
||||
T=TRN, E=0, I=0, S=664, L=1352, P=21504, Y=664, Z=640
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[0] Unknown encoding: 24 signal bits
|
||||
Signal: SS:LL:SS:LL:SS:SS:LL:LL:SS:LL:SS:LL:SP
|
||||
T=UNK, E=0, I=23908, S=650, L=1348, P=23912, Y=0, Z=656
|
||||
T=UNK, E=0, I=21504, S=640, L=1336, P=21504, Y=0, Z=656
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=664
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[2] Unknown encoding: 24 signal bits
|
||||
Signal: SS:LL:SS:LL:SS:LL:SS:LL:SS:SL:SS:LL:SP
|
||||
T=UNK, E=0, I=0, S=650, L=1348, P=23936, Y=0, Z=656
|
||||
T=UNK, E=0, I=0, S=640, L=1336, P=21504, Y=0, Z=656
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23956, Y=650, Z=628
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=624
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[0] Unknown encoding: 24 signal bits
|
||||
Signal: SS:LL:SS:LL:SS:SS:LL:LL:SS:LL:SS:LL:SP
|
||||
T=UNK, E=0, I=23908, S=650, L=1348, P=23912, Y=0, Z=700
|
||||
T=UNK, E=0, I=21504, S=640, L=1336, P=21504, Y=0, Z=656
|
||||
[1] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23936, Y=650, Z=664
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[2] Received 11 bits(!): 02 ad
|
||||
T=TRN, E=1, I=0, S=650, L=1348, P=23936, Y=650, Z=636
|
||||
T=TRN, E=1, I=0, S=640, L=1336, P=21504, Y=640, Z=656
|
||||
[3] Received 12 bits: 05 55
|
||||
T=TRN, E=0, I=0, S=650, L=1348, P=23956, Y=650, Z=672
|
||||
T=TRN, E=0, I=0, S=640, L=1336, P=21504, Y=640, Z=624
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 11
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 7
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 7
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 8
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 8
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=2500, V=2500, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2432, V=2432, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 8
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 8
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 9
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 9
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 10
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 10
|
||||
T=SYN, E=0, I=14916, S(lo)=340, L(lo)=340, S(hi)=368, L(hi)=368, P=3724, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=336, L(lo)=336, S(hi)=368, L(hi)=368, P=3712, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=354, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 9
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=3000, V=3000, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2944, V=2944, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 9
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=3000, V=3000, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=2944, V=2944, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 10
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=1200, V=1200, Y=0, Z=348
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=1200, V=1200, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=344
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[0] Sync 10
|
||||
T=SYN, E=0, I=14916, S(lo)=356, L(lo)=356, S(hi)=364, L(hi)=364, P=3724, U=1200, V=1200, Y=0, Z=340
|
||||
T=SYN, E=0, I=14848, S(lo)=352, L(lo)=352, S(hi)=352, L(hi)=352, P=3712, U=1200, V=1200, Y=0, Z=336
|
||||
[1] Received 55 bits: 50 8f 1a 30 08 98 cf
|
||||
T=TRI, E=0, I=0, S=360, L=734, P=3000, Y=0, Z=356
|
||||
T=TRI, E=0, I=0, S=352, L=728, P=2944, Y=0, Z=704
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
0, 30937
|
||||
4244, 1488
|
||||
360, 720
|
||||
360, 720
|
||||
724, 360
|
||||
360, 720
|
||||
360, 720
|
||||
360, 720
|
||||
720, 360
|
||||
360, 724
|
||||
720, 360
|
||||
720, 360
|
||||
720, 360
|
||||
720, 364
|
||||
360, 724
|
||||
720, 364
|
||||
360, 724
|
||||
720, 364
|
||||
356, 724
|
||||
720, 360
|
||||
356, 724
|
||||
360, 724
|
||||
720, 364
|
||||
356, 724
|
||||
356, 724
|
||||
360, 728
|
||||
356, 724
|
||||
360, 724
|
||||
356, 724
|
||||
356, 724
|
||||
356, 724
|
||||
720, 364
|
||||
356, 724
|
||||
720, 364
|
||||
356, 724
|
||||
716, 364
|
||||
356, 724
|
||||
716, 364
|
||||
356, 724
|
||||
720, 364
|
||||
356, 728
|
||||
716, 7844
|
||||
4840, 1500
|
||||
356, 728
|
||||
356, 728
|
||||
716, 364
|
||||
356, 720
|
||||
356, 728
|
||||
356, 728
|
||||
716, 368
|
||||
356, 728
|
||||
716, 364
|
||||
716, 368
|
||||
712, 368
|
||||
716, 368
|
||||
352, 728
|
||||
716, 368
|
||||
352, 728
|
||||
716, 368
|
||||
352, 728
|
||||
716, 368
|
||||
352, 728
|
||||
352, 728
|
||||
716, 368
|
||||
352, 728
|
||||
352, 728
|
||||
352, 728
|
||||
352, 728
|
|
@ -0,0 +1,22 @@
|
|||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt = -t 3
|
||||
|
||||
ALL: $(target)
|
||||
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
|
@ -0,0 +1,346 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
# 2. Upload to Arduino
|
||||
# 3. Read (continually) what is arriving from the USB port the Arduino is
|
||||
# connected to
|
||||
|
||||
# Versions history (as of 1.3)
|
||||
# 1.3 Output from Arduino is recorded in files named with numbers instead of
|
||||
# date-time string.
|
||||
# 1.4 Adds -t (--testplan) option, to set TESTPLAN macro
|
||||
# 1.5 -t (or --testplan) now comes with a value, so as to manage multiple test
|
||||
# plans.
|
||||
# 1.6 Updated to work fine with Arch arduino package instead of the manually
|
||||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
SPEED=
|
||||
FQBN=
|
||||
BUILDDIR=
|
||||
RECORDDIR=out
|
||||
READSPEED=
|
||||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
function finish {
|
||||
if [ "${DISPLAYSEP}" == "yes" ]; then
|
||||
echo "-----END ARDUINO OUTPUT-----" | tee -a "${RECORDFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap finish EXIT
|
||||
|
||||
function usage {
|
||||
echo "Usage:"
|
||||
echo " am [OPTIONS...] FILE"
|
||||
echo "Compile FILE using arduino-builder."
|
||||
echo "Example: am sketch.ino"
|
||||
echo ""
|
||||
echo "ENVIRONMENT VARIABLES"
|
||||
echo " If ARDUINO_USER_LIBS is defined and non empty, then arduino-builder"
|
||||
echo " is called with the supplementary option -libraries followed by"
|
||||
echo " ARDUINO_USER_LIBS' value."
|
||||
echo ""
|
||||
echo "OPTIONS"
|
||||
echo " -h --help Display this help screen"
|
||||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
echo " Normally, speed is infered from device type:"
|
||||
echo " 115200 for Uno, 57600 for Nano"
|
||||
echo " -B --fqbn Board Fully Qualified Name, like 'arduino:avr:uno'"
|
||||
echo " -d --builddir Build directory"
|
||||
echo " -c --catusb Display (continually) what Arduino writes on USB"
|
||||
echo " --stty Tune stty properly for later communication (implied"
|
||||
echo " by --catusb)"
|
||||
echo " -r --recordusb Write USB (continually) to a file (implies -c)"
|
||||
echo " --recordfile Output file if -r option is set"
|
||||
echo " -n --nocompile Don't compile code"
|
||||
echo " --readspeed Read speed of USB. If not specified, this script"
|
||||
echo " will try to infere it from source file. If it"
|
||||
echo " fails, it'll fallback to 9600."
|
||||
echo " This option is useful only if USB is read"
|
||||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function version {
|
||||
echo "am version ${VERSION}"
|
||||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help ) usage; shift ;;
|
||||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
-B | --fqbn ) FQBN="$2"; shift 2 ;;
|
||||
-d | --builddir ) BUILDDIR="$2"; shift 2 ;;
|
||||
-c | --catusb ) CATUSB="yes"; shift ;;
|
||||
-r | --recordusb ) RECORDUSB="yes"; CATUSB="yes"; shift ;;
|
||||
-n | --nocompile ) COMPILE="no"; shift ;;
|
||||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
FILE=${1:-}
|
||||
TRAILINGOPTS=${2:-}
|
||||
|
||||
if [ -n "${TRAILINGOPTS}" ]; then
|
||||
echo "Error: trailing options"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -z "${FILE}" ]; then
|
||||
echo "Error: no input file"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
set +e
|
||||
|
||||
if [ -n "${BOARD}" ]; then
|
||||
if [ "${BOARD}" != "uno" ] && [ "${BOARD}" != "nano" ]; then
|
||||
echo "Error: board '${BOARD}' unknown"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
COUNTNANO=$(compgen -G '/dev/ttyUSB*' | wc -l)
|
||||
|
||||
if [ -z "${BOARD}" ]; then
|
||||
if [ "${COUNTUNO}" -ge 1 ] && [ "${COUNTNANO}" -ge 1 ]; then
|
||||
echo "Error: cannot guess board, found ${COUNTUNO} uno(s), ${COUNTNANO} nano(s)"
|
||||
exit 10
|
||||
fi
|
||||
if [ "${COUNTUNO}" -ge 1 ]; then
|
||||
BOARD=uno
|
||||
elif [ "${COUNTNANO}" -ge 1 ]; then
|
||||
BOARD=nano
|
||||
fi
|
||||
if [ -z "${BOARD}" ]; then
|
||||
echo "Error: cannot guess board, none found";
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ] || [ "${CATUSB}" == "yes" ]; then
|
||||
if [ -z "${PORT}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
COUNT=${COUNTUNO}
|
||||
PORT=$(compgen -G '/dev/ttyACM*')
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
COUNT=${COUNTNANO}
|
||||
PORT=$(compgen -G '/dev/ttyUSB*')
|
||||
else
|
||||
echo "FATAL #001, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if [ "${COUNT}" -ge 2 ]; then
|
||||
echo "Error: cannot guess port, more than 1 board '${BOARD}' found"
|
||||
exit 10
|
||||
fi
|
||||
if [ -z "${PORT}" ]; then
|
||||
echo "Error: cannot guess port, none found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${SPEED}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
SPEED=115200
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
SPEED=57600
|
||||
else
|
||||
echo "FATAL #002, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "${PORT}" ]; then
|
||||
echo "Error: port not found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${FQBN}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
FQBN="arduino:avr:uno"
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
FQBN="arduino:avr:nano:cpu=atmega328old"
|
||||
else
|
||||
echo "FATAL #003, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [[ "${FILE}" == */* ]]; then
|
||||
BUILDDIR=${FILE%/*}
|
||||
BUILDDIR="${BUILDDIR%/}/build"
|
||||
else
|
||||
BUILDDIR=build
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${RECORDUSB}" == "yes" ]; then
|
||||
if [ -z "${RECORDFILE}" ]; then
|
||||
V=${FILE##*/}
|
||||
V=${V%.*}
|
||||
V=${V:-out}
|
||||
PREV=
|
||||
for i in {15..00}; do
|
||||
F="${RECORDDIR}/${V}-$i.txt"
|
||||
if [ -e "${F}" ] && [ -n "${PREV}" ]; then
|
||||
mv "${F}" "${PREV}"
|
||||
fi
|
||||
PREV="${F}"
|
||||
done
|
||||
RECORDFILE="${F}"
|
||||
mkdir -p "${RECORDDIR}"
|
||||
fi
|
||||
else
|
||||
RECORDFILE="/dev/null"
|
||||
fi
|
||||
|
||||
if [ "${VERBOSE}" == "yes" ]; then
|
||||
echo "-- Settings"
|
||||
echo "Arduino dir: ${ARDUINODIR}"
|
||||
echo "Board: ${BOARD}"
|
||||
echo "Port: ${PORT}"
|
||||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
echo "Verbose: ${VERBOSE}"
|
||||
echo "File: ${FILE}"
|
||||
echo "Build dir: ${BUILDDIR}"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
mkdir -p "${BUILDDIR}"
|
||||
|
||||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
||||
if [ -z "${READSPEED}" ]; then
|
||||
TFILE=$(mktemp)
|
||||
gcc -fpreprocessed -dD -x c++ -E "${FILE}" > "${TFILE}"
|
||||
for sp in 9600 19200 28800 38400 57600 115200; do
|
||||
if grep ${sp} "${TFILE}" > /dev/null; then
|
||||
READSPEED=${sp}
|
||||
fi
|
||||
done
|
||||
READSPEED=${READSPEED:-9600}
|
||||
rm "${TFILE}"
|
||||
fi
|
||||
|
||||
stty -F "${PORT}" -hupcl -echo "${READSPEED}"
|
||||
echo "-- usb setup with speed ${READSPEED}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ]; then
|
||||
echo "-- Read usb (Ctrl-C to quit)"
|
||||
DISPLAYSEP=yes
|
||||
{
|
||||
echo "speed=${READSPEED}"
|
||||
echo "fqbn=${FQBN}"
|
||||
echo "port=${PORT}"
|
||||
echo "file=${FILE}"
|
||||
echo "filedate=$(date +"%Y-%m-%dT%H:%M:%SZ" -d @$(stat -c '%Y' "${FILE}"))"
|
||||
echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
echo ""
|
||||
echo "-----BEGIN ARDUINO OUTPUT-----"
|
||||
} | tee "${RECORDFILE}"
|
||||
tee -a "${RECORDFILE}" < "${PORT}"
|
||||
fi
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
0, 14100,
|
||||
480, 1344,
|
||||
1340, 484,
|
||||
480, 1348,
|
||||
1388, 484,
|
||||
484, 1348,
|
||||
504, 1344,
|
||||
1344, 480,
|
||||
1364, 508,
|
||||
1348, 480,
|
||||
484, 1348,
|
||||
1388, 480,
|
||||
1372, 476,
|
||||
1364, 480,
|
||||
1324, 484,
|
||||
476, 1352,
|
||||
1332, 508,
|
||||
456, 1348,
|
||||
456, 1348,
|
||||
456, 1344,
|
||||
504, 1348,
|
||||
1340, 484,
|
||||
1360, 484,
|
||||
1368, 480,
|
||||
484, 1348,
|
||||
460, 14048,
|
||||
480, 1344,
|
||||
1388, 480,
|
||||
484, 1348,
|
||||
1348, 480,
|
||||
476, 1348,
|
||||
460, 1340,
|
||||
1340, 480,
|
||||
1364, 508,
|
||||
1344, 480,
|
||||
484, 1348,
|
||||
1388, 480,
|
||||
1372, 484,
|
||||
1360, 480,
|
||||
1328, 480,
|
||||
480, 1344,
|
||||
1340, 508,
|
||||
456, 1348,
|
||||
456, 1344,
|
||||
460, 1340,
|
||||
504, 1348,
|
||||
1340, 484,
|
||||
1360, 484,
|
||||
1316, 480,
|
||||
444, 1340,
|
||||
468, 14096,
|
||||
476, 1348,
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
-----CODE START-----
|
||||
// [WRITE THE DEVICE NAME HERE]
|
||||
rf.register_Receiver(
|
||||
RFMOD_TRIBIT, // mod
|
||||
29696, // initseq
|
||||
4224, // lo_prefix
|
||||
1488, // hi_prefix
|
||||
0, // first_lo_ign
|
||||
352, // lo_short
|
||||
720, // lo_long
|
||||
0, // hi_short (0 => take lo_short)
|
||||
0, // hi_long (0 => take lo_long)
|
||||
704, // lo_last
|
||||
7808, // sep
|
||||
39 // nb_bits
|
||||
);
|
||||
-----CODE END-----
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
0, 10696
|
||||
352, 424
|
||||
564, 1036
|
||||
560, 1028
|
||||
568, 1028
|
||||
560, 1028
|
||||
564, 1032
|
||||
360, 420
|
||||
576, 1020
|
||||
368, 412
|
||||
368, 412
|
||||
376, 412
|
||||
376, 420
|
||||
364, 420
|
||||
368, 428
|
||||
360, 424
|
||||
568, 1036
|
||||
360, 428
|
||||
568, 1028
|
||||
372, 412
|
||||
372, 412
|
||||
380, 408
|
||||
580, 1028
|
||||
576, 1028
|
||||
368, 420
|
||||
568, 1036
|
||||
368, 412
|
||||
380, 412
|
||||
372, 412
|
||||
376, 412
|
||||
376, 412
|
||||
584, 1020
|
||||
576, 1028
|
||||
368, 420
|
||||
572, 1028
|
||||
576, 1020
|
||||
384, 408
|
||||
380, 408
|
||||
580, 1024
|
||||
584, 1020
|
||||
576, 1028
|
||||
372, 416
|
||||
572, 1028
|
||||
376, 412
|
||||
584, 1020
|
||||
376, 412
|
||||
584, 1024
|
||||
372, 412
|
||||
376, 416
|
|
@ -0,0 +1,54 @@
|
|||
0, 30000
|
||||
356, 360
|
||||
356, 360
|
||||
356, 360
|
||||
356, 360
|
||||
352, 360
|
||||
352, 360
|
||||
352, 360
|
||||
356, 360
|
||||
352, 360
|
||||
356, 3236
|
||||
0, 3236
|
||||
356, 356
|
||||
356, 716
|
||||
364, 352
|
||||
360, 352
|
||||
716, 360
|
||||
352, 712
|
||||
364, 352
|
||||
716, 360
|
||||
352, 376
|
||||
340, 360
|
||||
352, 716
|
||||
716, 712
|
||||
364, 352
|
||||
364, 352
|
||||
360, 352
|
||||
364, 352
|
||||
364, 352
|
||||
712, 364
|
||||
352, 716
|
||||
360, 352
|
||||
364, 352
|
||||
716, 712
|
||||
716, 716
|
||||
712, 720
|
||||
360, 352
|
||||
364, 352
|
||||
364, 352
|
||||
360, 352
|
||||
716, 716
|
||||
360, 352
|
||||
716, 716
|
||||
712, 716
|
||||
716, 712
|
||||
716, 716
|
||||
712, 716
|
||||
716, 360
|
||||
352, 372
|
||||
344, 712
|
||||
716, 716
|
||||
712, 716
|
||||
1076,30000
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
0, 3236
|
||||
356, 356
|
||||
356, 716
|
||||
364, 352
|
||||
360, 352
|
||||
716, 360
|
||||
352, 712
|
||||
364, 352
|
||||
716, 360
|
||||
352, 376
|
||||
340, 360
|
||||
352, 716
|
||||
716, 712
|
||||
364, 352
|
||||
364, 352
|
||||
360, 352
|
||||
364, 352
|
||||
364, 352
|
||||
712, 364
|
||||
352, 716
|
||||
360, 352
|
||||
364, 352
|
||||
716, 712
|
||||
716, 716
|
||||
712, 720
|
||||
360, 352
|
||||
364, 352
|
||||
364, 352
|
||||
360, 352
|
||||
716, 716
|
||||
360, 352
|
||||
716, 716
|
||||
712, 716
|
||||
716, 712
|
||||
716, 716
|
||||
712, 716
|
||||
716, 360
|
||||
352, 372
|
||||
344, 712
|
||||
716, 716
|
||||
712, 716
|
||||
1076, 30000
|
|
@ -0,0 +1,211 @@
|
|||
// simul.ino
|
||||
|
||||
// Perform RF433any library test plan
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
||||
`RF433any' is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
`RF433any' is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
//
|
||||
// Schematic: see RF433any library
|
||||
//
|
||||
|
||||
#define PIN_RFINPUT 2
|
||||
|
||||
#include "RF433any.h"
|
||||
|
||||
#include "RF433Serial.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
extern uint16_t sim_timings_count;
|
||||
extern unsigned int counter;
|
||||
extern unsigned int sim_int_count;
|
||||
extern char buffer[RF433SERIAL_LINE_BUF_LEN];
|
||||
extern RF433SerialLine sl;
|
||||
extern duration_t sim_timings[SIM_TIMINGS_LEN];
|
||||
|
||||
#define ASSERT_OUTPUT_TO_SERIAL
|
||||
|
||||
#define assert(cond) { \
|
||||
if (!(cond)) { \
|
||||
assert_failed(__LINE__); \
|
||||
} \
|
||||
}
|
||||
|
||||
static void assert_failed(int line) {
|
||||
#ifdef ASSERT_OUTPUT_TO_SERIAL
|
||||
Serial.print("\ntest.ino:");
|
||||
Serial.print(line);
|
||||
Serial.println(": assertion failed, aborted.");
|
||||
#endif
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
char serial_printf_buffer[100];
|
||||
void serial_printf(const char* msg, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
|
||||
// NOTE
|
||||
// Assume Serial has been initialized (Serial.begin(...))
|
||||
void serial_printf(const char* msg, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
|
||||
vsnprintf(serial_printf_buffer, sizeof(serial_printf_buffer), msg, args);
|
||||
va_end(args);
|
||||
Serial.print(serial_printf_buffer);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(PIN_RFINPUT, INPUT);
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
Track track(PIN_RFINPUT);
|
||||
|
||||
void read_simulated_timings_from_usb() {
|
||||
sim_timings_count = 0;
|
||||
sim_int_count = 0;
|
||||
counter = 0;
|
||||
buffer[0] = '\0';
|
||||
for ( ;
|
||||
strcmp(buffer, ".");
|
||||
sl.get_line_blocking(buffer, sizeof(buffer))
|
||||
) {
|
||||
|
||||
if (!strlen(buffer))
|
||||
continue;
|
||||
|
||||
dbgf("==READ LINE [%s]", buffer);
|
||||
|
||||
char *p = buffer;
|
||||
while (*p != ',' && *p != '\0')
|
||||
++p;
|
||||
if (*p != ',') {
|
||||
dbg("FATAL: each line must have a ',' character!");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
unsigned int l = atoi(buffer);
|
||||
unsigned int h = atoi(p + 1);
|
||||
|
||||
if (sim_timings_count >=
|
||||
sizeof(sim_timings) / sizeof(*sim_timings) - 1) {
|
||||
dbg("FATAL: timings buffer full!");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
sim_timings[sim_timings_count++] = compact(l);
|
||||
sim_timings[sim_timings_count++] = compact(h);
|
||||
}
|
||||
}
|
||||
|
||||
#if RF433ANY_TESTPLAN == 5
|
||||
void output_decoder(Decoder *pdec) {
|
||||
while (pdec) {
|
||||
dbgf("Decoded: %s, err: %d, code: %c, "
|
||||
"rep: %d, bits: %2d",
|
||||
(pdec->data_got_decoded() ? "yes" : "no "),
|
||||
pdec->get_nb_errors(), pdec->get_id_letter(),
|
||||
pdec->get_repeats() + 1, pdec->get_nb_bits());
|
||||
|
||||
if (pdec->data_got_decoded()) {
|
||||
Serial.print(" Data: ");
|
||||
if (pdec->get_pdata()) {
|
||||
char *buf = pdec->get_pdata()->to_str();
|
||||
if (buf) {
|
||||
Serial.print(buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
Serial.print("\n");
|
||||
}
|
||||
pdec = pdec->get_next();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *encoding_names[] = {
|
||||
"R", // T
|
||||
"R", // N
|
||||
"R", // M
|
||||
"<" // Anything else
|
||||
};
|
||||
|
||||
const char *id_letter_to_encoding_name(char c) {
|
||||
if (c == 'T')
|
||||
return encoding_names[0];
|
||||
else if (c == 'N')
|
||||
return encoding_names[1];
|
||||
else if (c == 'M')
|
||||
return encoding_names[2];
|
||||
|
||||
return encoding_names[3];
|
||||
}
|
||||
|
||||
void output_timings(Decoder *pdec, byte nb_bits) {
|
||||
TimingsExt tsext;
|
||||
if (!pdec)
|
||||
return;
|
||||
pdec->get_tsext(&tsext);
|
||||
|
||||
const char *enc_name = id_letter_to_encoding_name(pdec->get_id_letter());
|
||||
|
||||
dbg("\n-----CODE START-----");
|
||||
dbg("// [WRITE THE DEVICE NAME HERE]\n"
|
||||
"rf.register_Receiver(");
|
||||
dbgf("\t%s, // mod", enc_name);
|
||||
dbgf("\t%u, // initseq", tsext.initseq);
|
||||
dbgf("\t%u, // lo_prefix", tsext.first_low);
|
||||
dbgf("\t%u, // hi_prefix", tsext.first_high);
|
||||
dbgf("\t%u, // first_lo_ign", tsext.first_low_ignored);
|
||||
dbgf("\t%u, // lo_short", tsext.low_short);
|
||||
dbgf("\t%u, // lo_long", tsext.low_long);
|
||||
dbgf("\t%u, // hi_short (0 => take lo_short)", tsext.high_short);
|
||||
dbgf("\t%u, // hi_long (0 => take lo_long)", tsext.high_long);
|
||||
dbgf("\t%u, // lo_last", tsext.last_low);
|
||||
dbgf("\t%u, // sep", tsext.sep);
|
||||
dbgf("\t%u // nb_bits", nb_bits);
|
||||
dbg(");");
|
||||
dbg("-----CODE END-----\n");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (sim_int_count >= sim_timings_count)
|
||||
read_simulated_timings_from_usb();
|
||||
|
||||
++counter;
|
||||
|
||||
track.treset();
|
||||
while (track.get_trk() != TRK_DATA && sim_int_count <= sim_timings_count) {
|
||||
Track::ih_handle_interrupt();
|
||||
track.do_events();
|
||||
}
|
||||
track.force_stop_recv();
|
||||
|
||||
Decoder *pdec = track.get_data(0);
|
||||
if (pdec) {
|
||||
int nb_bits = pdec->get_nb_bits();
|
||||
output_timings(pdec, nb_bits);
|
||||
delete pdec;
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4:sw=4:tw=80:et
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PORT=/dev/ttyUSB0
|
||||
INP_FILE=${1:-}
|
||||
|
||||
if [ "${INP_FILE}" == "" ]; then
|
||||
echo "Usage:"
|
||||
echo " ./simul.sh code_file"
|
||||
echo
|
||||
echo "You have to update the variable PORT defined at the"
|
||||
echo "beginning of this script. At the moment it is:"
|
||||
echo "${PORT}"
|
||||
echo
|
||||
echo "code_file contains lines of timings in the form"
|
||||
echo "low_duration,high_duration"
|
||||
echo "For example:"
|
||||
echo "0,10000"
|
||||
echo "300,500"
|
||||
echo "300,500"
|
||||
echo "500,300"
|
||||
echo "300,5000"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./am2 -R -t 4 simul.ino -u
|
||||
stty -F "${PORT}" -hupcl -echo 115200
|
||||
cat "${PORT}" &
|
||||
|
||||
sleep 1
|
||||
|
||||
cat "${INP_FILE}" > "${PORT}"
|
||||
echo "." > "${PORT}"
|
||||
|
||||
sleep 1
|
||||
|
||||
# From
|
||||
# https://unix.stackexchange.com/questions/43527/kill-all-background-jobs
|
||||
kill $(jobs -p)
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,104 @@
|
|||
0,183488
|
||||
7600, 2508
|
||||
7272, 1084
|
||||
684, 320
|
||||
300, 724
|
||||
300, 724
|
||||
676, 332
|
||||
688, 344
|
||||
292, 716
|
||||
684, 340
|
||||
676, 352
|
||||
676, 352
|
||||
676, 352
|
||||
288, 740
|
||||
676, 352
|
||||
676, 352
|
||||
288, 740
|
||||
668, 348
|
||||
292, 744
|
||||
292, 744
|
||||
280, 736
|
||||
288, 736
|
||||
292, 732
|
||||
292, 736
|
||||
668, 356
|
||||
668, 356
|
||||
284, 752
|
||||
284, 748
|
||||
280, 744
|
||||
280, 748
|
||||
676, 352
|
||||
280, 744
|
||||
284, 748
|
||||
284, 744
|
||||
280, 744
|
||||
284, 748
|
||||
672, 364
|
||||
272, 744
|
||||
676, 360
|
||||
280, 740
|
||||
280, 752
|
||||
280, 748
|
||||
664, 372
|
||||
276, 748
|
||||
664, 360
|
||||
668, 364
|
||||
664, 368
|
||||
272, 756
|
||||
660, 368
|
||||
272, 756
|
||||
660, 380
|
||||
272, 716
|
||||
7232, 1112
|
||||
660, 368
|
||||
272, 756
|
||||
264, 764
|
||||
656, 368
|
||||
656, 372
|
||||
260, 764
|
||||
656, 368
|
||||
656, 380
|
||||
648, 384
|
||||
652, 372
|
||||
260, 764
|
||||
656, 372
|
||||
644, 380
|
||||
260, 772
|
||||
648, 380
|
||||
256, 780
|
||||
256, 768
|
||||
256, 760
|
||||
268, 756
|
||||
268, 760
|
||||
268, 756
|
||||
660, 376
|
||||
648, 376
|
||||
264, 764
|
||||
272, 756
|
||||
272, 756
|
||||
264, 764
|
||||
648, 376
|
||||
264, 768
|
||||
264, 764
|
||||
260, 764
|
||||
264, 776
|
||||
260, 768
|
||||
648, 380
|
||||
260, 764
|
||||
644, 384
|
||||
264, 764
|
||||
260, 764
|
||||
252, 764
|
||||
656, 380
|
||||
260, 764
|
||||
656, 372
|
||||
656, 372
|
||||
656, 380
|
||||
256, 760
|
||||
656, 384
|
||||
256, 760
|
||||
656, 380
|
||||
268, 728
|
||||
7212, 1120
|
||||
640, 388
|
|
@ -1,10 +1,22 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDUINO_LIBS = RF433any
|
||||
ARDMK_DIR = /home/sebastien/.arduino_mk
|
||||
# This Makefile is to be symbolic-linked inside subfolders.
|
||||
# It is generic enough that, to the asumption the subfolder contains one .ino
|
||||
# file and only one, it'll work as expected.
|
||||
|
||||
# USER_LIB_PATH = /home/sebastien/travail/cpp/seb/arduino/libraries
|
||||
source = $(wildcard *.ino)
|
||||
target = build/$(source).with_bootloader.hex
|
||||
opt = -t 1
|
||||
|
||||
BOARD_TAG = uno
|
||||
MCU = atmega328
|
||||
ALL: $(target)
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
||||
$(target): $(source)
|
||||
ifdef color
|
||||
./am2 $(opt) $<
|
||||
else
|
||||
GCC_COLORS="" ./am2 --no-color $(opt) $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
mrproper:
|
||||
rm -rf build out
|
||||
|
|
|
@ -0,0 +1,346 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# am2
|
||||
|
||||
# Copyright 2019, 2020, 2021, 2022 Sébastien Millet
|
||||
|
||||
# Can perform the following:
|
||||
# 1. Compile the code
|
||||
# 2. Upload to Arduino
|
||||
# 3. Read (continually) what is arriving from the USB port the Arduino is
|
||||
# connected to
|
||||
|
||||
# Versions history (as of 1.3)
|
||||
# 1.3 Output from Arduino is recorded in files named with numbers instead of
|
||||
# date-time string.
|
||||
# 1.4 Adds -t (--testplan) option, to set TESTPLAN macro
|
||||
# 1.5 -t (or --testplan) now comes with a value, so as to manage multiple test
|
||||
# plans.
|
||||
# 1.6 Updated to work fine with Arch arduino package instead of the manually
|
||||
# installed (from tar.gz source) package used so far.
|
||||
# 1.7 Renames archlinux-arduino back to arduino, and created corresponding
|
||||
# symlink (was cleaner to do s).
|
||||
# 2.0 Replaces arduino-builder with arduino-cli
|
||||
# 2.1 Output warning if ARDUINO_USER_LIBS environment variable is not set
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=2.1
|
||||
|
||||
PORT=
|
||||
BOARD=
|
||||
SPEED=
|
||||
FQBN=
|
||||
BUILDDIR=
|
||||
RECORDDIR=out
|
||||
READSPEED=
|
||||
RECORDFILE=
|
||||
|
||||
UPLOAD="no"
|
||||
REMOVE="no"
|
||||
VERBOSE="no"
|
||||
CATUSB="no"
|
||||
STTY="no"
|
||||
RECORDUSB="no"
|
||||
COMPILE="yes"
|
||||
TESTPLAN=
|
||||
NOCOLOR=
|
||||
|
||||
DISPLAYSEP=no
|
||||
|
||||
function finish {
|
||||
if [ "${DISPLAYSEP}" == "yes" ]; then
|
||||
echo "-----END ARDUINO OUTPUT-----" | tee -a "${RECORDFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
trap finish EXIT
|
||||
|
||||
function usage {
|
||||
echo "Usage:"
|
||||
echo " am [OPTIONS...] FILE"
|
||||
echo "Compile FILE using arduino-builder."
|
||||
echo "Example: am sketch.ino"
|
||||
echo ""
|
||||
echo "ENVIRONMENT VARIABLES"
|
||||
echo " If ARDUINO_USER_LIBS is defined and non empty, then arduino-builder"
|
||||
echo " is called with the supplementary option -libraries followed by"
|
||||
echo " ARDUINO_USER_LIBS' value."
|
||||
echo ""
|
||||
echo "OPTIONS"
|
||||
echo " -h --help Display this help screen"
|
||||
echo " -V --version Output version information and quit"
|
||||
echo " -v --verbose Be more talkative"
|
||||
echo " -u --upload Upload compiled code into Arduino"
|
||||
echo " -R --remove Remove /tmp/arduino-core-cache and ./buid"
|
||||
echo " -b --board Board, either 'uno' or 'nano'"
|
||||
echo " -p --port Port, for ex. '/dev/ttyUSB0'"
|
||||
echo " -s --speed Upload speed, for ex. 115200"
|
||||
echo " Normally, speed is infered from device type:"
|
||||
echo " 115200 for Uno, 57600 for Nano"
|
||||
echo " -B --fqbn Board Fully Qualified Name, like 'arduino:avr:uno'"
|
||||
echo " -d --builddir Build directory"
|
||||
echo " -c --catusb Display (continually) what Arduino writes on USB"
|
||||
echo " --stty Tune stty properly for later communication (implied"
|
||||
echo " by --catusb)"
|
||||
echo " -r --recordusb Write USB (continually) to a file (implies -c)"
|
||||
echo " --recordfile Output file if -r option is set"
|
||||
echo " -n --nocompile Don't compile code"
|
||||
echo " --readspeed Read speed of USB. If not specified, this script"
|
||||
echo " will try to infere it from source file. If it"
|
||||
echo " fails, it'll fallback to 9600."
|
||||
echo " This option is useful only if USB is read"
|
||||
echo " (-c or --stty option set)"
|
||||
echo " -t --testplan Set TESTPLAN macro value"
|
||||
echo " (as if #define TESTPLAN VALUE)"
|
||||
echo " --no-color Pass on the --no-color option to arduino-cli"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function version {
|
||||
echo "am version ${VERSION}"
|
||||
exit
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hVvuRb:p:s:B:d:crnt: --long help,version,verbose,upload,remove,board:,port:,speed:,fqbn:,builddir:,catusb,stty,no-color,recordusb,nocompile,readspeed:,recordfile:,testplan: -n 'am' -- "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help ) usage; shift ;;
|
||||
-V | --version ) version; shift ;;
|
||||
-v | --verbose ) VERBOSE="yes"; shift ;;
|
||||
-u | --upload ) UPLOAD="yes"; shift ;;
|
||||
-R | --remove ) REMOVE="yes"; shift ;;
|
||||
-b | --board ) BOARD="$2"; shift 2 ;;
|
||||
-p | --port ) PORT="$2"; shift 2 ;;
|
||||
-s | --speed ) SPEED="$2"; shift 2 ;;
|
||||
-B | --fqbn ) FQBN="$2"; shift 2 ;;
|
||||
-d | --builddir ) BUILDDIR="$2"; shift 2 ;;
|
||||
-c | --catusb ) CATUSB="yes"; shift ;;
|
||||
-r | --recordusb ) RECORDUSB="yes"; CATUSB="yes"; shift ;;
|
||||
-n | --nocompile ) COMPILE="no"; shift ;;
|
||||
--readspeed ) READSPEED="$2"; shift 2 ;;
|
||||
--recordfile ) RECORDFILE="$2"; shift 2 ;;
|
||||
--stty ) STTY="yes"; shift ;;
|
||||
--no-color ) NOCOLOR="--no-color"; shift ;;
|
||||
-t | --testplan ) TESTPLAN="$2"; shift 2 ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
FILE=${1:-}
|
||||
TRAILINGOPTS=${2:-}
|
||||
|
||||
if [ -n "${TRAILINGOPTS}" ]; then
|
||||
echo "Error: trailing options"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -z "${FILE}" ]; then
|
||||
echo "Error: no input file"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
set +e
|
||||
|
||||
if [ -n "${BOARD}" ]; then
|
||||
if [ "${BOARD}" != "uno" ] && [ "${BOARD}" != "nano" ]; then
|
||||
echo "Error: board '${BOARD}' unknown"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ARDUINODIR=/usr/share/arduino
|
||||
|
||||
COUNTUNO=$(compgen -G '/dev/ttyACM*' | wc -l)
|
||||
COUNTNANO=$(compgen -G '/dev/ttyUSB*' | wc -l)
|
||||
|
||||
if [ -z "${BOARD}" ]; then
|
||||
if [ "${COUNTUNO}" -ge 1 ] && [ "${COUNTNANO}" -ge 1 ]; then
|
||||
echo "Error: cannot guess board, found ${COUNTUNO} uno(s), ${COUNTNANO} nano(s)"
|
||||
exit 10
|
||||
fi
|
||||
if [ "${COUNTUNO}" -ge 1 ]; then
|
||||
BOARD=uno
|
||||
elif [ "${COUNTNANO}" -ge 1 ]; then
|
||||
BOARD=nano
|
||||
fi
|
||||
if [ -z "${BOARD}" ]; then
|
||||
echo "Error: cannot guess board, none found";
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ] || [ "${CATUSB}" == "yes" ]; then
|
||||
if [ -z "${PORT}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
COUNT=${COUNTUNO}
|
||||
PORT=$(compgen -G '/dev/ttyACM*')
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
COUNT=${COUNTNANO}
|
||||
PORT=$(compgen -G '/dev/ttyUSB*')
|
||||
else
|
||||
echo "FATAL #001, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if [ "${COUNT}" -ge 2 ]; then
|
||||
echo "Error: cannot guess port, more than 1 board '${BOARD}' found"
|
||||
exit 10
|
||||
fi
|
||||
if [ -z "${PORT}" ]; then
|
||||
echo "Error: cannot guess port, none found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${SPEED}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
SPEED=115200
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
SPEED=57600
|
||||
else
|
||||
echo "FATAL #002, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "${PORT}" ]; then
|
||||
echo "Error: port not found"
|
||||
exit 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${FQBN}" ]; then
|
||||
if [ "${BOARD}" == "uno" ]; then
|
||||
FQBN="arduino:avr:uno"
|
||||
elif [ "${BOARD}" == "nano" ]; then
|
||||
FQBN="arduino:avr:nano:cpu=atmega328old"
|
||||
else
|
||||
echo "FATAL #003, CHECK THIS CODE"
|
||||
exit 99
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [[ "${FILE}" == */* ]]; then
|
||||
BUILDDIR=${FILE%/*}
|
||||
BUILDDIR="${BUILDDIR%/}/build"
|
||||
else
|
||||
BUILDDIR=build
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${RECORDUSB}" == "yes" ]; then
|
||||
if [ -z "${RECORDFILE}" ]; then
|
||||
V=${FILE##*/}
|
||||
V=${V%.*}
|
||||
V=${V:-out}
|
||||
PREV=
|
||||
for i in {15..00}; do
|
||||
F="${RECORDDIR}/${V}-$i.txt"
|
||||
if [ -e "${F}" ] && [ -n "${PREV}" ]; then
|
||||
mv "${F}" "${PREV}"
|
||||
fi
|
||||
PREV="${F}"
|
||||
done
|
||||
RECORDFILE="${F}"
|
||||
mkdir -p "${RECORDDIR}"
|
||||
fi
|
||||
else
|
||||
RECORDFILE="/dev/null"
|
||||
fi
|
||||
|
||||
if [ "${VERBOSE}" == "yes" ]; then
|
||||
echo "-- Settings"
|
||||
echo "Arduino dir: ${ARDUINODIR}"
|
||||
echo "Board: ${BOARD}"
|
||||
echo "Port: ${PORT}"
|
||||
echo "Speed: ${SPEED}"
|
||||
echo "Fqbn: ${FQBN}"
|
||||
echo "Upload: ${UPLOAD}"
|
||||
echo "Remove: ${REMOVE}"
|
||||
echo "Catusb: ${CATUSB}"
|
||||
echo "Recordusb: ${RECORDUSB}"
|
||||
echo "Record file: ${RECORDFILE}"
|
||||
echo "Verbose: ${VERBOSE}"
|
||||
echo "File: ${FILE}"
|
||||
echo "Build dir: ${BUILDDIR}"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
if [ "${REMOVE}" == "yes" ]; then
|
||||
rm -rf /tmp/arduino-core-cache
|
||||
fi
|
||||
|
||||
if [ "${COMPILE}" == "yes" ]; then
|
||||
echo "-- Compile"
|
||||
|
||||
mkdir -p "${BUILDDIR}"
|
||||
|
||||
OPT_LIB=
|
||||
TMP_ULIB=${ARDUINO_USER_LIBS:-}
|
||||
if [ -n "${TMP_ULIB}" ]; then
|
||||
OPT_LIB="--libraries ""${TMP_ULIB}"""
|
||||
else
|
||||
echo
|
||||
echo "***********************************************************"
|
||||
echo "* WARNING *"
|
||||
echo "* The environment variable ARDUINO_USER_LIBS is not set *"
|
||||
echo "***********************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
TESTPLAN_OPT=""
|
||||
if [ -n "${TESTPLAN}" ]; then
|
||||
TESTPLAN_OPT="--build-property build.extra_flags=-DRF433ANY_TESTPLAN=${TESTPLAN}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
# (We don't want to quote OPT_LIB as it can contain multiple options.)
|
||||
arduino-cli compile -b "${FQBN}" ${NOCOLOR} --build-path "${BUILDDIR}" ${OPT_LIB} ${TESTPLAN_OPT} "${FILE}"
|
||||
fi
|
||||
|
||||
FILEBASENAME=${FILE##*/}
|
||||
|
||||
if [ "${UPLOAD}" == "yes" ]; then
|
||||
echo "-- Upload"
|
||||
arduino-cli upload -v -b "${FQBN}" --input-dir "${BUILDDIR}" -p "${PORT}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ] || [ "${STTY}" == "yes" ]; then
|
||||
if [ -z "${READSPEED}" ]; then
|
||||
TFILE=$(mktemp)
|
||||
gcc -fpreprocessed -dD -x c++ -E "${FILE}" > "${TFILE}"
|
||||
for sp in 9600 19200 28800 38400 57600 115200; do
|
||||
if grep ${sp} "${TFILE}" > /dev/null; then
|
||||
READSPEED=${sp}
|
||||
fi
|
||||
done
|
||||
READSPEED=${READSPEED:-9600}
|
||||
rm "${TFILE}"
|
||||
fi
|
||||
|
||||
stty -F "${PORT}" -hupcl -echo "${READSPEED}"
|
||||
echo "-- usb setup with speed ${READSPEED}"
|
||||
fi
|
||||
|
||||
if [ "${CATUSB}" == "yes" ]; then
|
||||
echo "-- Read usb (Ctrl-C to quit)"
|
||||
DISPLAYSEP=yes
|
||||
{
|
||||
echo "speed=${READSPEED}"
|
||||
echo "fqbn=${FQBN}"
|
||||
echo "port=${PORT}"
|
||||
echo "file=${FILE}"
|
||||
echo "filedate=$(date +"%Y-%m-%dT%H:%M:%SZ" -d @$(stat -c '%Y' "${FILE}"))"
|
||||
echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
echo ""
|
||||
echo "-----BEGIN ARDUINO OUTPUT-----"
|
||||
} | tee "${RECORDFILE}"
|
||||
tee -a "${RECORDFILE}" < "${PORT}"
|
||||
fi
|
||||
|
|
@ -27,19 +27,19 @@
|
|||
#define PIN_RFINPUT 2
|
||||
|
||||
#include "RF433any.h"
|
||||
#include "Serial.h"
|
||||
#include "RF433Serial.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
extern uint16_t sim_timings_count;
|
||||
extern unsigned int counter;
|
||||
extern unsigned int sim_int_count;
|
||||
extern char buffer[SERIAL_LINE_BUF_LEN];
|
||||
extern SerialLine sl;
|
||||
extern uint16_t sim_timings[SIM_TIMINGS_LEN];
|
||||
extern char buffer[RF433SERIAL_LINE_BUF_LEN];
|
||||
extern RF433SerialLine sl;
|
||||
extern duration_t sim_timings[SIM_TIMINGS_LEN];
|
||||
extern unsigned int sim_int_count_svg;
|
||||
|
||||
bool filter_mask_set;
|
||||
uint16_t filter_mask;
|
||||
uint16_t filter_mask = 0;
|
||||
|
||||
#define ASSERT_OUTPUT_TO_SERIAL
|
||||
|
||||
|
@ -103,12 +103,12 @@ void read_simulated_timings_from_usb() {
|
|||
filter_mask_set = true;
|
||||
filter_mask = l;
|
||||
} else {
|
||||
sim_timings[sim_timings_count++] = l;
|
||||
sim_timings[sim_timings_count++] = h;
|
||||
sim_timings[sim_timings_count++] = compact(l);
|
||||
sim_timings[sim_timings_count++] = compact(h);
|
||||
}
|
||||
#else
|
||||
sim_timings[sim_timings_count++] = l;
|
||||
sim_timings[sim_timings_count++] = h;
|
||||
sim_timings[sim_timings_count++] = compact(l);
|
||||
sim_timings[sim_timings_count++] = compact(h);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,51 @@ void output_decoder(Decoder *pdec) {
|
|||
}
|
||||
#endif
|
||||
|
||||
const char *encoding_names[] = {
|
||||
"RFMOD_TRIBIT", // T
|
||||
"RFMOD_TRIBIT_INVERTED", // N
|
||||
"RFMOD_MANCHESTER", // M
|
||||
"<unmanaged encoding>" // Anything else
|
||||
};
|
||||
|
||||
const char *id_letter_to_encoding_name(char c) {
|
||||
if (c == 'T')
|
||||
return encoding_names[0];
|
||||
else if (c == 'N')
|
||||
return encoding_names[1];
|
||||
else if (c == 'M')
|
||||
return encoding_names[2];
|
||||
|
||||
return encoding_names[3];
|
||||
}
|
||||
|
||||
void output_timings(Decoder *pdec, byte nb_bits) {
|
||||
TimingsExt tsext;
|
||||
if (!pdec)
|
||||
return;
|
||||
pdec->get_tsext(&tsext);
|
||||
|
||||
const char *enc_name = id_letter_to_encoding_name(pdec->get_id_letter());
|
||||
|
||||
dbg("\n-----CODE START-----");
|
||||
dbg("// [WRITE THE DEVICE NAME HERE]\n"
|
||||
"rf.register_Receiver(");
|
||||
dbgf("\t%s, // mod", enc_name);
|
||||
dbgf("\t%u, // initseq", tsext.initseq);
|
||||
dbgf("\t%u, // lo_prefix", tsext.first_low);
|
||||
dbgf("\t%u, // hi_prefix", tsext.first_high);
|
||||
dbgf("\t%u, // first_lo_ign", tsext.first_low_ignored);
|
||||
dbgf("\t%u, // lo_short", tsext.low_short);
|
||||
dbgf("\t%u, // lo_long", tsext.low_long);
|
||||
dbgf("\t%u, // hi_short (0 => take lo_short)", tsext.high_short);
|
||||
dbgf("\t%u, // hi_long (0 => take lo_long)", tsext.high_long);
|
||||
dbgf("\t%u, // lo_last", tsext.last_low);
|
||||
dbgf("\t%u, // sep", tsext.sep);
|
||||
dbgf("\t%u // nb_bits", nb_bits);
|
||||
dbg(");");
|
||||
dbg("-----CODE END-----\n");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (sim_int_count >= sim_timings_count)
|
||||
read_simulated_timings_from_usb();
|
||||
|
@ -176,6 +221,10 @@ void loop() {
|
|||
if (pdec) {
|
||||
#ifdef RF433ANY_DBG_DECODER
|
||||
pdec->dbg_decoder(2);
|
||||
// if (pdec) {
|
||||
// int nb_bits = pdec->get_nb_bits();
|
||||
// output_timings(pdec, nb_bits);
|
||||
// }
|
||||
#endif
|
||||
#if RF433ANY_TESTPLAN == 5
|
||||
output_decoder(pdec);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue