fix little endian vs big endian in the macros... again... but this time correct
[RRG-proxmark3.git] / client / src / pm3.c
bloba4c9518c31f925bf72cc265b56dbc4843437dfa5
1 //-----------------------------------------------------------------------------
2 // User API
3 //-----------------------------------------------------------------------------
5 #include "pm3.h"
7 #include <stdlib.h>
9 #include "proxmark3.h"
10 #include "cmdmain.h"
11 #include "ui.h"
12 #include "usart_defs.h"
13 #include "util_posix.h"
14 #include "comms.h"
16 pm3_device *pm3_open(char *port) {
17 pm3_init();
18 OpenProxmark(&session.current_device, port, false, 20, false, USART_BAUD_RATE);
19 if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
20 PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark\n");
21 CloseProxmark(session.current_device);
24 if ((port != NULL) && (!session.pm3_present))
25 exit(EXIT_FAILURE);
27 if (!session.pm3_present)
28 PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode");
29 // For now, there is no real device context:
30 return session.current_device;
33 void pm3_close(pm3_device *dev) {
34 // Clean up the port
35 if (session.pm3_present) {
36 clearCommandBuffer();
37 SendCommandNG(CMD_QUIT_SESSION, NULL, 0);
38 msleep(100); // Make sure command is sent before killing client
39 CloseProxmark(dev);
43 int pm3_console(pm3_device *dev, char *Cmd) {
44 // For now, there is no real device context:
45 (void) dev;
46 return CommandReceived(Cmd);
49 const char *pm3_name_get(pm3_device *dev) {
50 return dev->conn->serial_port_name;
53 pm3_device *pm3_get_current_dev(void) {
54 return session.current_device;