mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
chg: 'hw connect' - make port optional. Reused previous serial port
This commit is contained in:
parent
61d250a7f8
commit
fb7445a027
3 changed files with 22 additions and 19 deletions
|
@ -6,6 +6,7 @@
|
||||||
// the license.
|
// the license.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Hardware commands
|
// Hardware commands
|
||||||
|
// low-level hardware control
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -19,8 +20,6 @@
|
||||||
#include "cmdmain.h"
|
#include "cmdmain.h"
|
||||||
#include "cmddata.h"
|
#include "cmddata.h"
|
||||||
|
|
||||||
/* low-level hardware control */
|
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_hw_detectreader(void) {
|
static int usage_hw_detectreader(void) {
|
||||||
|
@ -58,8 +57,7 @@ static int usage_hw_connect(void) {
|
||||||
PrintAndLogEx(NORMAL, " <port> serial port to connect to");
|
PrintAndLogEx(NORMAL, " <port> serial port to connect to");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " hw connect /dev/ttyACM0 -- *nix ");
|
PrintAndLogEx(NORMAL, " hw connect "SERIAL_PORT_H);
|
||||||
PrintAndLogEx(NORMAL, " hw connect com3 -- windows");
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,24 +505,24 @@ static int CmdConnect(const char *Cmd) {
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
port = (char *)Cmd;
|
port = (char *)Cmd;
|
||||||
|
|
||||||
if (port != NULL) {
|
// default back to previous used serial port
|
||||||
|
if (strlen(port) == 0 )
|
||||||
|
GetSavedSerialPortName( &port );
|
||||||
|
|
||||||
// if we were already connected, disconnect first.
|
// if we were already connected, disconnect first.
|
||||||
if (session.pm3_present) {
|
if (session.pm3_present) {
|
||||||
PrintAndLogEx(INFO, "Disconnecting from current serial port");
|
PrintAndLogEx(INFO, "Disconnecting from current serial port");
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
session.pm3_present = false;
|
session.pm3_present = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to open serial port
|
// try to open serial port
|
||||||
session.pm3_present = OpenProxmark(port, false, 20, false, USART_BAUD_RATE);
|
session.pm3_present = OpenProxmark(port, false, 20, false, USART_BAUD_RATE);
|
||||||
|
|
||||||
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
||||||
PrintAndLogEx(ERR, _RED_("ERROR:") "cannot communicate with the Proxmark\n");
|
PrintAndLogEx(ERR, _RED_("ERROR:") "cannot communicate with the Proxmark\n");
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
session.pm3_present = false;
|
session.pm3_present = false;
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ static uint64_t timeout_start_time;
|
||||||
|
|
||||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
||||||
|
|
||||||
|
void GetSavedSerialPortName( char **dest ) {
|
||||||
|
*dest = serial_port_name;
|
||||||
|
}
|
||||||
|
|
||||||
void SendCommand(PacketCommandOLD *c) {
|
void SendCommand(PacketCommandOLD *c) {
|
||||||
|
|
||||||
#ifdef COMMS_DEBUG
|
#ifdef COMMS_DEBUG
|
||||||
|
|
|
@ -62,6 +62,7 @@ void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, v
|
||||||
void clearCommandBuffer(void);
|
void clearCommandBuffer(void);
|
||||||
|
|
||||||
#define FLASHMODE_SPEED 460800
|
#define FLASHMODE_SPEED 460800
|
||||||
|
void GetSavedSerialPortName( char **dest );
|
||||||
bool IsCommunicationThreadDead(void);
|
bool IsCommunicationThreadDead(void);
|
||||||
bool ReConnectProxmark(void);
|
bool ReConnectProxmark(void);
|
||||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue