-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squash merge dev branch into main. Changes:
* Refactoring: moved global defines to digilivolo.h, code split into 2 additional units based on functions: usb_func.[ch] which handles USB HID related things & args.[ch] which handles command line options, help and copyright messages. * Some text messages from software improved. * Added comment headers to source files. * hidapi version requirement set to 0.13 (as it's in fact). * Added arm-linux-gnueabihf-gcc-toolchain.cmake file for cross-compiling arm binaries.
- Loading branch information
Showing
16 changed files
with
461 additions
and
188 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...b/workflows/build-firmware-platformio.yml → .github/workflows/build-firmware.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_PROCESSOR arm) | ||
|
||
SET (TRIPLET arm-linux-gnueabihf) | ||
SET(CMAKE_C_COMPILER ${TRIPLET}-gcc) | ||
|
||
# Build for Cortex-A7 if required | ||
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a7 -mtune=cortex-a7") | ||
|
||
# set path(s) to search for libraries/binaries/headers | ||
# SET (CMAKE_FIND_ROOT_PATH /usr/${TRIPLET} /usr/lib/${TRIPLET} /usr/include /usr/include/${TRIPLET}) | ||
# ensure only cross-dirs are searched | ||
# SET (ONLY_CMAKE_FIND_ROOT_PATH TRUE) | ||
|
||
# We have cross pkg-config installed instead | ||
SET(PKG_CONFIG_EXECUTABLE ${TRIPLET}-pkg-config) | ||
|
||
# search for programs in the build host directories | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
# for libraries and headers in the target directories | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* Part of the DigiLivolo control software. | ||
* https://github.com/N-Storm/DigiLivolo/ | ||
* Copyright (c) 2024 GitHub user N-Storm. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
#include <stdio.h> | ||
#include <wchar.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#include "digilivolo.h" | ||
|
||
#include <hidapi.h> | ||
#include "usb_func.h" | ||
|
||
#include "git_version.h" | ||
#include "args.h" | ||
|
||
// [argp] Program documentation. | ||
// const char* argp_program_version = GIT_VERSION; | ||
const char prognamever[] = "digilivolo " GIT_VERSION "\n"; | ||
const char doc[] = "\nSoftware to control DigiLivolo devices.\n"; | ||
|
||
const char* argp_program_bug_address = "https://github.com/N-Storm/DigiLivolo/\n\ | ||
Copyright (c) 2024 GitHub user N-Storm.\n\ | ||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"; | ||
|
||
// [argp] A description of the arguments we accept. | ||
char args_doc[] = "REMOTE_ID KEY_ID"; | ||
|
||
// [argp] The options we understand. | ||
struct argp_option options[] = { | ||
{0, 0, 0, 0, "Positional arguments:" }, | ||
{"REMOTE_ID", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "Livilo Remote ID (1-65535)" }, | ||
{"KEY_ID", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "Livilo Key ID (1-255)" }, | ||
{0, 0, 0, 0, "Options:" }, | ||
{"verbose", 'v', 0, 0, "Produce verbose output" }, | ||
{ 0 } | ||
}; | ||
|
||
// [argp] Command-line arguments. | ||
arguments_t arguments; | ||
|
||
// [argp] Parse a single option. | ||
error_t parse_opt(int key, char* arg, struct argp_state* state) | ||
{ | ||
/* Get the input argument from argp_parse, which we | ||
* know is a pointer to our arguments structure. */ | ||
struct arguments* arguments = state->input; | ||
|
||
switch (key) { | ||
case 'v': | ||
arguments->verbose = true; | ||
break; | ||
|
||
case ARGP_KEY_ARG: | ||
if (state->arg_num >= 2) | ||
// Too many arguments. | ||
argp_usage(state); | ||
|
||
char* endptr; | ||
// Convert argument to long | ||
long value = strtol(arg, &endptr, 0); | ||
// Check if it was valid long value | ||
if (*endptr == '\0') { | ||
switch (state->arg_num) { | ||
case 0: | ||
// Out of range | ||
if (value > 65535 || value <= 0) | ||
argp_usage(state); | ||
else | ||
arguments->remote_id = (uint16_t)value; | ||
break; | ||
|
||
case 1: | ||
// Out of range | ||
if (value > 255 || value <= 0) | ||
argp_usage(state); | ||
else | ||
arguments->key_id = (uint8_t)value; | ||
break; | ||
|
||
default: | ||
return ARGP_ERR_UNKNOWN; | ||
} | ||
} | ||
else | ||
// REMOTE_ID or KEY_ID not an unsigned integer | ||
argp_usage(state); | ||
|
||
break; | ||
|
||
case ARGP_KEY_END: | ||
if (state->arg_num < 2) | ||
// Not enough arguments. | ||
argp_usage(state); | ||
break; | ||
|
||
default: | ||
return ARGP_ERR_UNKNOWN; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Part of the DigiLivolo control software. | ||
* https://github.com/N-Storm/DigiLivolo/ | ||
* Copyright (c) 2024 GitHub user N-Storm. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#ifndef __args_h__ | ||
#define __args_h__ | ||
|
||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#include "digilivolo.h" | ||
|
||
#include "git_version.h" | ||
#include <argp.h> | ||
|
||
// [argp] A description of the arguments we accept. | ||
extern char args_doc[]; | ||
|
||
// [argp] The options we understand. | ||
extern struct argp_option options[]; | ||
|
||
// [argp] Program documentation. | ||
// const char* argp_program_version = GIT_VERSION; | ||
extern const char prognamever[]; | ||
extern const char doc[]; | ||
extern const char* argp_program_bug_address; | ||
|
||
// [argp] Command-line arguments. | ||
typedef struct arguments { | ||
uint16_t remote_id; | ||
uint8_t key_id; | ||
bool verbose; | ||
} arguments_t; | ||
|
||
extern arguments_t arguments; | ||
|
||
extern error_t parse_opt(int key, char* arg, struct argp_state* state); | ||
|
||
#endif // __args_h__ |
Oops, something went wrong.