Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Kharisov <ah@bright-box.com>2021-09-10 00:37:32 +0300
committerGitHub <noreply@github.com>2021-09-10 00:37:32 +0300
commitfbccb9fbafd543c2f7683be6de8ac9393250e9cd (patch)
tree6f1686eb8446939839679c214b608827d361ea4e /applications/irda
parent9bce160ca6aff2b139cd230aad2709e192be8117 (diff)
[FL-1684] IRDA Add SIRC protocol (#693)
* IRDA HAL: Fill buffer refactoring * IRDA: Add SIRC protocol * IRDA: correct adr/cmd bit length * Disable Unit tests Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/irda')
-rw-r--r--applications/irda/cli/irda-cli.cpp18
-rw-r--r--applications/irda/irda-app-file-parser.cpp12
-rw-r--r--applications/irda/scene/irda-app-scene-edit-delete.cpp4
-rw-r--r--applications/irda/scene/irda-app-scene-learn-enter-name.cpp2
-rw-r--r--applications/irda/scene/irda-app-scene-learn-success.cpp4
5 files changed, 27 insertions, 13 deletions
diff --git a/applications/irda/cli/irda-cli.cpp b/applications/irda/cli/irda-cli.cpp
index 1becdfbb..f9906b5c 100644
--- a/applications/irda/cli/irda-cli.cpp
+++ b/applications/irda/cli/irda-cli.cpp
@@ -25,9 +25,9 @@ static void signal_received_callback(void* context, IrdaWorkerSignal* received_s
sizeof(buf),
"%s, A:0x%0*lX, C:0x%0*lX%s\r\n",
irda_get_protocol_name(message->protocol),
- irda_get_protocol_address_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_address_length(message->protocol), 4),
message->address,
- irda_get_protocol_command_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_command_length(message->protocol), 4),
message->command,
message->repeat ? " R" : "");
cli_write(cli, (uint8_t*)buf, buf_cnt);
@@ -98,6 +98,20 @@ static bool parse_message(const char* str, IrdaMessage* message) {
return false;
}
+ uint32_t address_length = irda_get_protocol_address_length(protocol);
+ uint32_t address_mask = (1LU << address_length) - 1;
+ if(address != (address & address_mask)) {
+ printf("Address out of range (mask 0x%08lX): 0x%lX\r\n", address_mask, address);
+ return false;
+ }
+
+ uint32_t command_length = irda_get_protocol_command_length(protocol);
+ uint32_t command_mask = (1LU << command_length) - 1;
+ if(command != (command & command_mask)) {
+ printf("Command out of range (mask 0x%08lX): 0x%lX\r\n", command_mask, command);
+ return false;
+ }
+
message->protocol = protocol;
message->address = address;
message->command = command;
diff --git a/applications/irda/irda-app-file-parser.cpp b/applications/irda/irda-app-file-parser.cpp
index f462919e..3ab14fc0 100644
--- a/applications/irda/irda-app-file-parser.cpp
+++ b/applications/irda/irda-app-file-parser.cpp
@@ -45,9 +45,9 @@ size_t IrdaAppFileParser::stringify_message(
"%.31s %.31s A:%0*lX C:%0*lX\n",
name,
irda_get_protocol_name(protocol),
- irda_get_protocol_address_length(protocol),
+ ROUND_UP_TO(irda_get_protocol_address_length(protocol), 4),
message.address,
- irda_get_protocol_command_length(protocol),
+ ROUND_UP_TO(irda_get_protocol_command_length(protocol), 4),
message.command);
furi_assert(written < buf_size);
@@ -162,8 +162,8 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal>
return nullptr;
}
- int address_length = irda_get_protocol_address_length(protocol);
- uint32_t address_mask = (1LU << (4 * address_length)) - 1;
+ uint32_t address_length = irda_get_protocol_address_length(protocol);
+ uint32_t address_mask = (1LU << address_length) - 1;
if(address != (address & address_mask)) {
size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30);
FURI_LOG_E(
@@ -176,8 +176,8 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal>
return nullptr;
}
- int command_length = irda_get_protocol_command_length(protocol);
- uint32_t command_mask = (1LU << (4 * command_length)) - 1;
+ uint32_t command_length = irda_get_protocol_command_length(protocol);
+ uint32_t command_mask = (1LU << command_length) - 1;
if(command != (command & command_mask)) {
size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30);
FURI_LOG_E(
diff --git a/applications/irda/scene/irda-app-scene-edit-delete.cpp b/applications/irda/scene/irda-app-scene-edit-delete.cpp
index c5d1cdd7..ff11cc19 100644
--- a/applications/irda/scene/irda-app-scene-edit-delete.cpp
+++ b/applications/irda/scene/irda-app-scene-edit-delete.cpp
@@ -29,9 +29,9 @@ void IrdaAppSceneEditDelete::on_enter(IrdaApp* app) {
"%s\n%s\nA=0x%0*lX C=0x%0*lX",
remote_manager->get_button_name(app->get_current_button()).c_str(),
irda_get_protocol_name(message->protocol),
- irda_get_protocol_address_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_address_length(message->protocol), 4),
message->address,
- irda_get_protocol_command_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_command_length(message->protocol), 4),
message->command);
} else {
app->set_text_store(
diff --git a/applications/irda/scene/irda-app-scene-learn-enter-name.cpp b/applications/irda/scene/irda-app-scene-learn-enter-name.cpp
index aa22d620..821ae9de 100644
--- a/applications/irda/scene/irda-app-scene-learn-enter-name.cpp
+++ b/applications/irda/scene/irda-app-scene-learn-enter-name.cpp
@@ -13,7 +13,7 @@ void IrdaAppSceneLearnEnterName::on_enter(IrdaApp* app) {
0,
"%.4s_%0*lX",
irda_get_protocol_name(message->protocol),
- irda_get_protocol_command_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_command_length(message->protocol), 4),
message->command);
} else {
auto raw_signal = signal.get_raw_signal();
diff --git a/applications/irda/scene/irda-app-scene-learn-success.cpp b/applications/irda/scene/irda-app-scene-learn-success.cpp
index 8fa0c87b..030ca0e3 100644
--- a/applications/irda/scene/irda-app-scene-learn-success.cpp
+++ b/applications/irda/scene/irda-app-scene-learn-success.cpp
@@ -27,9 +27,9 @@ void IrdaAppSceneLearnSuccess::on_enter(IrdaApp* app) {
app->set_text_store(
1,
"A: 0x%0*lX\nC: 0x%0*lX\n",
- irda_get_protocol_address_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_address_length(message->protocol), 4),
message->address,
- irda_get_protocol_command_length(message->protocol),
+ ROUND_UP_TO(irda_get_protocol_command_length(message->protocol), 4),
message->command);
dialog_ex_set_header(dialog_ex, app->get_text_store(0), 95, 10, AlignCenter, AlignCenter);
dialog_ex_set_text(dialog_ex, app->get_text_store(1), 75, 23, AlignLeft, AlignTop);