mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 18:57:12 +08:00
* using WITH_FPC: * activate basic usart * no double buffer for now, no interrupt * usart_dataavailable/usart_readbuffer/usart_writebuffer, to demo it: * pm3 client over USB, minicom over usart * analyse a d 414243 * using WITH_FPC_HOST: * it implies WITH_FPC as it's based on it * control pm3 with client over usart * EXPERIMENTAL! still some frame desync issues * you can connect both from usart & USB with two pm3 clients * actually you *have* to connect USB for the moment because it's used to send debug messages about buggy usart... See Dbprintf_usb below * "sessions": msgs are directed to the latest client to have sent a cmd * Dbprintf_usb macro to send msgs to USB client to help debugging usart... * We now have an option to run client at different speed as usart is 115200: client/proxmark3 /dev/ttyUSB0 -b 115200 * Consequently, argc,argv handling is a bit revamped, it was so messy... * USB and flashing are still at 460800, don't try flashing over usart yet ^^
69 lines
2.1 KiB
C
69 lines
2.1 KiB
C
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
|
|
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
|
//
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
// the license.
|
|
//-----------------------------------------------------------------------------
|
|
// Code for communicating with the proxmark3 hardware.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef COMMS_H_
|
|
#define COMMS_H_
|
|
|
|
#include <stdbool.h>
|
|
#include <pthread.h>
|
|
|
|
#include "usb_cmd.h"
|
|
#include "uart.h"
|
|
#include "ui.h"
|
|
#include "common.h"
|
|
#include "util_posix.h"
|
|
#include "util.h"
|
|
#include "util_darwin.h"
|
|
|
|
#if defined(__linux__) && !defined(NO_UNLINK)
|
|
#include <unistd.h> // for unlink()
|
|
#endif
|
|
|
|
//For storing command that are received from the device
|
|
#ifndef CMD_BUFFER_SIZE
|
|
#define CMD_BUFFER_SIZE 100
|
|
#endif
|
|
|
|
typedef enum {
|
|
BIG_BUF,
|
|
BIG_BUF_EML,
|
|
FLASH_MEM,
|
|
SIM_MEM,
|
|
} DeviceMemType_t;
|
|
|
|
typedef struct {
|
|
bool run; // If TRUE, continue running the uart_communication thread
|
|
bool block_after_ACK; // if true, block after receiving an ACK package
|
|
} communication_arg_t;
|
|
|
|
|
|
bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbCommand *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
|
|
|
void SetOffline(bool value);
|
|
bool IsOffline();
|
|
|
|
void *uart_receiver(void *targ);
|
|
void SendCommand(UsbCommand *c);
|
|
void clearCommandBuffer();
|
|
|
|
#define FLASHMODE_SPEED 460800
|
|
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
|
void CloseProxmark(void);
|
|
|
|
bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand *response, size_t ms_timeout, bool show_warning);
|
|
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand *response, size_t ms_timeout);
|
|
bool WaitForResponse(uint32_t cmd, UsbCommand *response);
|
|
|
|
extern bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbCommand *response, size_t ms_timeout, bool show_warning);
|
|
|
|
#endif
|
|
|
|
|