mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
char* port for OpenProxmark and remove global gui_serial_port_name
This commit is contained in:
parent
11e34237bb
commit
e3eb8b7401
4 changed files with 15 additions and 23 deletions
|
@ -580,7 +580,7 @@ static int CmdConnect(const char *Cmd) {
|
|||
|
||||
// default back to previous used serial port
|
||||
if (strlen(port) == 0) {
|
||||
if (strlen((char *)conn.serial_port_name) == 0) {
|
||||
if (strlen(conn.serial_port_name) == 0) {
|
||||
return usage_hw_connect();
|
||||
}
|
||||
memcpy(port, conn.serial_port_name, sizeof(port));
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
//#define COMMS_DEBUG
|
||||
//#define COMMS_DEBUG_RAW
|
||||
|
||||
uint8_t gui_serial_port_name[FILE_PATH_SIZE];
|
||||
|
||||
// Serial port that we are communicating with the PM3 on.
|
||||
static serial_port sp = NULL;
|
||||
|
||||
|
@ -537,19 +535,18 @@ bool IsCommunicationThreadDead(void) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||
bool OpenProxmark(char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||
|
||||
char *portname = (char *)port;
|
||||
if (!wait_for_port) {
|
||||
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), portname);
|
||||
sp = uart_open(portname, speed);
|
||||
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), port);
|
||||
sp = uart_open(port, speed);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), portname);
|
||||
PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), port);
|
||||
fflush(stdout);
|
||||
int openCount = 0;
|
||||
PrintAndLogEx(INPLACE, "% 3i", timeout);
|
||||
do {
|
||||
sp = uart_open(portname, speed);
|
||||
sp = uart_open(port, speed);
|
||||
msleep(500);
|
||||
PrintAndLogEx(INPLACE, "% 3i", timeout - openCount - 1);
|
||||
|
||||
|
@ -558,22 +555,19 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
|
||||
// check result of uart opening
|
||||
if (sp == INVALID_SERIAL_PORT) {
|
||||
PrintAndLogEx(WARNING, "\n" _RED_("ERROR:") " invalid serial port " _YELLOW_("%s"), portname);
|
||||
PrintAndLogEx(WARNING, "\n" _RED_("ERROR:") " invalid serial port " _YELLOW_("%s"), port);
|
||||
sp = NULL;
|
||||
return false;
|
||||
} else if (sp == CLAIMED_SERIAL_PORT) {
|
||||
PrintAndLogEx(WARNING, "\n" _RED_("ERROR:") " serial port " _YELLOW_("%s") " is claimed by another process", portname);
|
||||
PrintAndLogEx(WARNING, "\n" _RED_("ERROR:") " serial port " _YELLOW_("%s") " is claimed by another process", port);
|
||||
sp = NULL;
|
||||
return false;
|
||||
} else {
|
||||
// start the communication thread
|
||||
if (portname != (char *)conn.serial_port_name) {
|
||||
uint16_t len = MIN(strlen(portname), FILE_PATH_SIZE - 1);
|
||||
if (port != conn.serial_port_name) {
|
||||
uint16_t len = MIN(strlen(port), FILE_PATH_SIZE - 1);
|
||||
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
||||
memcpy(conn.serial_port_name, portname, len);
|
||||
|
||||
memset(gui_serial_port_name, 0, FILE_PATH_SIZE);
|
||||
memcpy(gui_serial_port_name, portname, len);
|
||||
memcpy(conn.serial_port_name, port, len);
|
||||
}
|
||||
conn.run = true;
|
||||
conn.block_after_ACK = flash_mode;
|
||||
|
|
|
@ -60,13 +60,11 @@ typedef struct {
|
|||
// To memorise baudrate
|
||||
uint32_t uart_speed;
|
||||
uint16_t last_command;
|
||||
uint8_t serial_port_name[FILE_PATH_SIZE];
|
||||
char serial_port_name[FILE_PATH_SIZE];
|
||||
} communication_arg_t;
|
||||
|
||||
extern communication_arg_t conn;
|
||||
|
||||
extern uint8_t gui_serial_port_name[FILE_PATH_SIZE];
|
||||
|
||||
void *uart_receiver(void *targ);
|
||||
void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
|
@ -76,7 +74,7 @@ void clearCommandBuffer(void);
|
|||
|
||||
#define FLASHMODE_SPEED 460800
|
||||
bool IsCommunicationThreadDead(void);
|
||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
bool OpenProxmark(char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
int TestProxmark(void);
|
||||
void CloseProxmark(void);
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
setLayout(layout);
|
||||
|
||||
// plot window title
|
||||
QString pt = QString("[*]Plot [ %1 ]").arg((char *)gui_serial_port_name);
|
||||
QString pt = QString("[*]Plot [ %1 ]").arg(conn.serial_port_name);
|
||||
setWindowTitle(pt);
|
||||
|
||||
// shows plot window on the screen.
|
||||
|
@ -247,7 +247,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
}
|
||||
|
||||
// Olverlays / slider window title
|
||||
QString ct = QString("[*]Slider [ %1 ]").arg((char *)gui_serial_port_name);
|
||||
QString ct = QString("[*]Slider [ %1 ]").arg(conn.serial_port_name);
|
||||
controlWidget->setWindowTitle(ct);
|
||||
|
||||
controlWidget->show();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue