Permalink
Browse files

Initial Wiegand support

Wiegand protocol is used on some access control devices.
https://en.wikipedia.org/wiki/Wiegand_interface

This mode allows to read/write on Wiegand interfaces.
  • Loading branch information...
Baldanos committed Sep 11, 2018
1 parent cb077a7 commit b3f3e1ba90d120ff5ec2b987667753ab1dca5947
View
@@ -210,6 +210,7 @@ static struct cmd_map {
{ T_TWOWIRE, cmd_mode_init },
{ T_THREEWIRE, cmd_mode_init },
{ T_FLASH, cmd_mode_init },
{ T_WIEGAND, cmd_mode_init },
{ 0, NULL }
};
View
@@ -115,6 +115,14 @@ typedef struct {
uint8_t dev_bit_lsb_msb;
} onewire_config_t;
typedef struct {
mode_dev_gpio_mode_t dev_gpio_mode;
mode_dev_gpio_pull_t dev_gpio_pull;
uint8_t dev_bit_lsb_msb;
uint32_t dev_pulse_width;
uint32_t dev_pulse_gap;
} wiegand_config_t;
typedef struct {
uint32_t dev_speed;
mode_dev_gpio_mode_t dev_gpio_mode;
@@ -151,6 +159,7 @@ typedef struct {
flash_config_t flash;
onewire_config_t onewire;
rawwire_config_t rawwire;
wiegand_config_t wiegand;
sump_config_t sump;
hydranfc_config_t hydranfc;
} config;
View
@@ -152,6 +152,7 @@ t_token_dict tl_dict[] = {
{ T_TS1, "ts1" },
{ T_TS2, "ts2" },
{ T_SJW, "sjw" },
{ T_WIEGAND, "wiegand" },
/* Developer warning add new command(s) here */
/* BP-compatible commands */
@@ -1192,11 +1193,6 @@ t_token tokens_mode_threewire[] = {
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Read byte (repeat with :<num>)"
},
{
T_HD,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Read byte (repeat with :<num>) and print hexdump"
},
{
T_WRITE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
@@ -1352,6 +1348,82 @@ t_token tokens_gpio[] = {
{ }
};
#define WIEGAND_PARAMETERS \
{ T_DEVICE, \
.arg_type = T_ARG_UINT, \
.help = "Wiegand device (1)" }, \
{ T_PULL, \
.arg_type = T_ARG_TOKEN, \
.subtokens = tokens_gpio_pull, \
.help = "GPIO pull (up/down/floating)" },
t_token tokens_mode_wiegand[] = {
{
T_SHOW,
.subtokens = tokens_mode_show,
.help = "Show wiegand parameters"
},
WIEGAND_PARAMETERS
/* wiegand-specific commands */
{
T_READ,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Read byte (repeat with :<num>)"
},
{
T_HD,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Read byte (repeat with :<num>) and print hexdump"
},
{
T_WRITE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write byte (repeat with :<num>)"
},
{
T_ARG_UINT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write byte (repeat with :<num>)"
},
{
T_ARG_STRING,
.help = "Write string"
},
/* BP commands */
{
T_MINUS,
.help = "Write one bit (D1)"
},
{
T_UNDERSCORE,
.help = "Write one bit (D0)"
},
{
T_AMPERSAND,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 usec (repeat with :<num>)"
},
{
T_PERCENT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 msec (repeat with :<num>)"
},
{
T_TILDE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write a random byte (repeat with :<num>)"
},
{
T_EXIT,
.help = "Exit wiegand mode"
},
{ }
};
t_token tokens_wiegand[] = {
WIEGAND_PARAMETERS
{ }
};
t_token tokens_adc[] = {
{
T_ADC1,
@@ -1698,6 +1770,11 @@ t_token tl_tokens[] = {
.subtokens = tokens_flash,
.help = "NAND flash mode"
},
{
T_WIEGAND,
.subtokens = tokens_wiegand,
.help = "Wiegand mode"
},
{
T_DEBUG,
.subtokens = tokens_debug,
View
@@ -144,6 +144,7 @@ enum {
T_TS1,
T_TS2,
T_SJW,
T_WIEGAND,
/* Developer warning add new command(s) here */
/* BP-compatible commands */
View
@@ -29,6 +29,7 @@ HYDRABUSSRC = hydrabus/hydrabus.c \
hydrabus/hydrabus_bbio_flash.c \
hydrabus/hydrabus_sd.c \
hydrabus/hydrabus_trigger.c \
hydrabus/hydrabus_mode_wiegand.c \
# Required include directories
HYDRABUSINC = ./hydrabus
@@ -48,6 +48,7 @@ extern const mode_exec_t mode_twowire_exec;
extern const mode_exec_t mode_threewire_exec;
extern const mode_exec_t mode_can_exec;
extern const mode_exec_t mode_flash_exec;
extern const mode_exec_t mode_wiegand_exec;
extern t_token tokens_mode_spi[];
extern t_token tokens_mode_i2c[];
extern t_token tokens_mode_uart[];
@@ -60,6 +61,7 @@ extern t_token tokens_mode_twowire[];
extern t_token tokens_mode_threewire[];
extern t_token tokens_mode_can[];
extern t_token tokens_mode_flash[];
extern t_token tokens_mode_wiegand[];
static struct {
int token;
@@ -78,6 +80,7 @@ static struct {
{ T_THREEWIRE, tokens_mode_threewire, &mode_threewire_exec },
{ T_CAN, tokens_mode_can, &mode_can_exec },
{ T_FLASH, tokens_mode_flash, &mode_flash_exec },
{ T_WIEGAND, tokens_mode_wiegand, &mode_wiegand_exec },
};
const char hydrabus_mode_str_cs_enabled[] = "/CS ENABLED\r\n";
Oops, something went wrong.

0 comments on commit b3f3e1b

Please sign in to comment.