mirror of https://github.com/sebmillet/RF433any
Adds simul directory
- Also fixes a possible bug in test.ino where a variable could be used without being set.
This commit is contained in:
parent
68f0d89732
commit
373c377b35
2
Makefile
2
Makefile
|
@ -7,6 +7,7 @@ clean:
|
||||||
make -C examples/04_react_on_code/ $@
|
make -C examples/04_react_on_code/ $@
|
||||||
make -C examples/05_callback/ $@
|
make -C examples/05_callback/ $@
|
||||||
make -C extras/testplan/test/ $@
|
make -C extras/testplan/test/ $@
|
||||||
|
make -C extras/testplan/simul/ $@
|
||||||
|
|
||||||
mrproper:
|
mrproper:
|
||||||
make -C examples/01_main/ $@
|
make -C examples/01_main/ $@
|
||||||
|
@ -15,4 +16,5 @@ mrproper:
|
||||||
make -C examples/04_react_on_code/ $@
|
make -C examples/04_react_on_code/ $@
|
||||||
make -C examples/05_callback/ $@
|
make -C examples/05_callback/ $@
|
||||||
make -C extras/testplan/test/ $@
|
make -C extras/testplan/test/ $@
|
||||||
|
make -C extras/testplan/simul/ $@
|
||||||
|
|
||||||
|
|
|
@ -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 @@
|
||||||
|
../../../am2
|
|
@ -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,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,208 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
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[] = {
|
||||||
|
"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();
|
||||||
|
|
||||||
|
++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 -t 3 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
|
|
@ -39,7 +39,7 @@ extern duration_t sim_timings[SIM_TIMINGS_LEN];
|
||||||
extern unsigned int sim_int_count_svg;
|
extern unsigned int sim_int_count_svg;
|
||||||
|
|
||||||
bool filter_mask_set;
|
bool filter_mask_set;
|
||||||
uint16_t filter_mask;
|
uint16_t filter_mask = 0;
|
||||||
|
|
||||||
#define ASSERT_OUTPUT_TO_SERIAL
|
#define ASSERT_OUTPUT_TO_SERIAL
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue