rename typedef struct pm3_device

This commit is contained in:
Philippe Teuwen 2021-08-21 21:41:52 +02:00
parent bae5362656
commit 5fce6271ee
9 changed files with 4081 additions and 3919 deletions

View file

@ -158,7 +158,7 @@ typedef struct {
typedef struct {
uint32_t blockdata;
bool valid;
} t55xx_memory_item_t ;
} t55xx_memory_item_t;
t55xx_conf_block_t Get_t55xx_Config(void);
void Set_t55xx_Config(t55xx_conf_block_t conf);

View file

@ -542,7 +542,7 @@ bool IsCommunicationThreadDead(void) {
return ret;
}
bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
bool OpenProxmark(pm3_device_t **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
if (!wait_for_port) {
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), port);
@ -593,7 +593,7 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout,
fflush(stdout);
if (*dev == NULL) {
*dev = calloc(sizeof(pm3_device), sizeof(uint8_t));
*dev = calloc(sizeof(pm3_device_t), sizeof(uint8_t));
}
(*dev)->g_conn = &g_conn; // TODO g_conn shouldn't be global
return true;
@ -601,7 +601,7 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout,
}
// check if we can communicate with Pm3
int TestProxmark(pm3_device *dev) {
int TestProxmark(pm3_device_t *dev) {
PacketResponseNG resp;
uint16_t len = 32;
@ -664,7 +664,7 @@ int TestProxmark(pm3_device *dev) {
return PM3_SUCCESS;
}
void CloseProxmark(pm3_device *dev) {
void CloseProxmark(pm3_device_t *dev) {
dev->g_conn->run = false;
#ifdef __BIONIC__

View file

@ -63,11 +63,10 @@ typedef struct {
extern communication_arg_t g_conn;
typedef struct pm3_device pm3_device;
struct pm3_device {
typedef struct pm3_device {
communication_arg_t *g_conn;
int script_embedded;
};
} pm3_device_t;
void *uart_receiver(void *targ);
void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
@ -78,10 +77,9 @@ void clearCommandBuffer(void);
#define FLASHMODE_SPEED 460800
bool IsCommunicationThreadDead(void);
typedef struct pm3_device pm3_device;
bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
int TestProxmark(pm3_device *dev);
void CloseProxmark(pm3_device *dev);
bool OpenProxmark(pm3_device_t **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
int TestProxmark(pm3_device_t *dev);
void CloseProxmark(pm3_device_t *dev);
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
bool WaitForResponseTimeout(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout);

View file

@ -13,7 +13,7 @@
#include "util_posix.h"
#include "comms.h"
pm3_device *pm3_open(char *port) {
pm3_device_t *pm3_open(char *port) {
pm3_init();
OpenProxmark(&g_session.current_device, port, false, 20, false, USART_BAUD_RATE);
if (g_session.pm3_present && (TestProxmark(g_session.current_device) != PM3_SUCCESS)) {
@ -30,7 +30,7 @@ pm3_device *pm3_open(char *port) {
return g_session.current_device;
}
void pm3_close(pm3_device *dev) {
void pm3_close(pm3_device_t *dev) {
// Clean up the port
if (g_session.pm3_present) {
clearCommandBuffer();
@ -40,16 +40,16 @@ void pm3_close(pm3_device *dev) {
}
}
int pm3_console(pm3_device *dev, char *Cmd) {
int pm3_console(pm3_device_t *dev, char *Cmd) {
// For now, there is no real device context:
(void) dev;
return CommandReceived(Cmd);
}
const char *pm3_name_get(pm3_device *dev) {
const char *pm3_name_get(pm3_device_t *dev) {
return dev->g_conn->serial_port_name;
}
pm3_device *pm3_get_current_dev(void) {
pm3_device_t *pm3_get_current_dev(void) {
return g_session.current_device;
}

View file

@ -12,13 +12,13 @@ typedef struct {
%extend {
pm3() {
// printf("SWIG pm3 constructor, get current pm3\n");
pm3_device * p = pm3_get_current_dev();
pm3_device_t * p = pm3_get_current_dev();
p->script_embedded = 1;
return p;
}
pm3(char *port) {
// printf("SWIG pm3 constructor with port, open pm3\n");
pm3_device * p = pm3_open(port);
pm3_device_t * p = pm3_open(port);
p->script_embedded = 0;
return p;
}

View file

@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.1
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -50,7 +50,7 @@ typedef struct {
// uint8_t device_debug_level;
uint16_t client_exe_delay;
char *history_path;
pm3_device *current_device;
pm3_device_t *current_device;
} session_arg_t;
extern session_arg_t g_session;