11 #define LIBMSR_ERR_OK 0x0 16 #define LIBMSR_ERR_GENERIC 0x1000 21 #define LIBMSR_ERR_ISO 0x1100 26 #define LIBMSR_ERR_DEVICE 0x2000 31 #define LIBMSR_ERR_SERIAL 0x4000 36 #define MSR_MAX_TRACK_LEN 255 41 #define MSR_MAX_TRACKS 3 43 #define MSR_BLOCKING O_NONBLOCK 44 #define MSR_BAUD B9600 59 #define MSR_STS_OK 0x30 64 #define MSR_STS_ERR 0x41 79 #define MSR_CMD_READ 0x72 84 #define MSR_CMD_WRITE 0x77 89 #define MSR_CMD_RAW_READ 0x6D 94 #define MSR_CMD_RAW_WRITE 0x6E 99 #define MSR_STS_RW_ERR 0x31 104 #define MSR_STS_RW_CMDFMT_ERR 0x32 109 #define MSR_STS_RW_CMDBAD_ERR 0x34 114 #define MSR_STS_RW_SWIPEBAD_ERR 0x39 132 #define MSR_RW_START 0x73 133 #define MSR_RW_END 0x3F 134 #define MSR_RW_BAD 0x2A 135 #define MSR_RW_EMPTY 0x2B 140 #define MSR_CMD_DIAG_COMM 0x65 145 #define MSR_STS_COMM_OK 0x79 150 #define MSR_CMD_DIAG_SENSOR 0x86 155 #define MSR_STS_SENSOR_OK MSR_STS_OK 160 #define MSR_CMD_DIAG_RAM 0x87 165 #define MSR_STS_RAM_OK MSR_STS_OK 170 #define MSR_STS_RAM_ERR MSR_STS_ERR 175 #define MSR_CMD_SLZ 0x7A 180 #define MSR_STS_SLZ_OK MSR_STS_OK 185 #define MSR_STS_SLZ_ERR MSR_STS_ERR 191 #define MSR_CMD_CLZ 0x6C 205 #define MSR_CMD_ERASE 0x63 210 #define MSR_STS_ERASE_OK MSR_STS_OK 215 #define MSR_STS_ERASE_ERR MSR_STS_ERR 220 #define MSR_ERASE_TK1 0x00 225 #define MSR_ERASE_TK2 0x02 230 #define MSR_ERASE_TK3 0x04 235 #define MSR_ERASE_TK1_TK2 0x03 240 #define MSR_ERASE_TK1_TK3 0x05 245 #define MSR_ERASE_TK2_TK3 0x06 250 #define MSR_ERASE_ALL 0x07 255 #define MSR_CMD_SETBPI 0x62 260 #define MSR_STS_BPI_OK MSR_STS_OK 265 #define MSR_STS_BPI_ERR MSR_STS_ERR 270 #define MSR_CMD_MODEL 0x74 275 #define MSR_STS_MODEL_OK 0x53 277 #define MSR_MODEL_MSR206_1 0x31 278 #define MSR_MODEL_MSR206_2 0x32 279 #define MSR_MODEL_MSR206_3 0x33 280 #define MSR_MODEL_MSR206_5 0x35 295 #define MSR_CMD_FWREV 0x76 300 #define MSR_FWREV_FMT "REV?X.XX" 305 #define MSR_CMD_SETBPC 0x6F 310 #define MSR_STS_BPC_OK MSR_STS_OK 315 #define MSR_STS_BPC_ERR MSR_STS_ERR 330 #define MSR_CMD_SETCO_HI 0x78 336 #define MSR_CMD_SETCO_LO 0x79 341 #define MSR_STS_CO_OK MSR_STS_OK 346 #define MSR_STS_CO_ERR MSR_STS_ERR 352 #define MSR_CMD_GETCO 0x64 357 #define MSR_CO_HI 0x68 362 #define MSR_CO_LO 0x6C 369 #define MSR_CMD_RESET 0x61 376 #define MSR_CMD_LED_OFF 0x81 383 #define MSR_CMD_LED_ON 0x82 390 #define MSR_CMD_LED_GRN_ON 0x83 397 #define MSR_CMD_LED_YLW_ON 0x84 404 #define MSR_CMD_LED_RED_ON 0x85 431 extern int msr_serial_open(
char *path,
int *fd,
int blocking, speed_t baud);
525 extern int msr_fwrev(
int fd, uint8_t *buf);
539 extern int msr_model(
int fd, uint8_t *buf);
736 extern int msr_erase(
int fd, uint8_t tracks);
794 extern int msr_set_bpc(
int fd, uint8_t bpc1, uint8_t bpc2, uint8_t bpc3);
uint8_t msr_bpctk2
Definition: libmsr.h:322
#define MSR_MAX_TRACKS
Definition: libmsr.h:41
int msr_serial_read(int fd, void *buf, size_t len)
Read a series of bytes from the MSR device.
Definition: serialio.c:35
void msr_pretty_output_bits(int fd, msr_tracks_t tracks)
Dump a "pretty" binary representation of tracks to a fd.
Definition: libmsr.c:198
Represents the MSR's BPC settings for each track.
Definition: libmsr.h:320
uint8_t msr_lz_tk2
Definition: libmsr.h:199
int msr_erase(int fd, uint8_t tracks)
Erase one or more tracks on a card.
Definition: msr206.c:423
uint8_t msr_s
Definition: libmsr.h:289
const unsigned char msr_reverse_byte(const unsigned char byte)
Reverse a single byte.
Definition: libmsr.c:227
int msr_set_hi_co(int fd)
Set the device's coercivity to high.
Definition: msr206.c:329
uint8_t msr_sts
Definition: libmsr.h:124
Represents all tracks on a magnetic card.
Definition: libmsr.h:417
int msr_set_bpi(int fd, uint8_t bpi)
Set the MSR device's BPI value.
Definition: msr206.c:559
int msr_fwrev(int fd, uint8_t *buf)
Check the device's firmware revision.
Definition: msr206.c:119
uint8_t msr_lz_tk1_3
Definition: libmsr.h:198
uint8_t msr_enddelim
Definition: libmsr.h:121
uint8_t msr_esc
Definition: libmsr.h:287
int msr_serial_readchar(int fd, uint8_t *c)
Read a single character from the MSR device.
Definition: serialio.c:17
struct msr_tracks msr_tracks_t
Represents all tracks on a magnetic card.
int msr_reverse_tracks(msr_tracks_t *tracks)
Reverse a msr_tracks_t structure in-place.
Definition: libmsr.c:132
int msr_iso_write(int fd, msr_tracks_t *tracks)
Write an ISO formatted card.
Definition: msr206.c:448
uint8_t msr_esc
Definition: libmsr.h:197
void msr_pretty_output_string(int fd, msr_tracks_t tracks)
Dump a "pretty" string representation of tracks to a fd.
Definition: libmsr.c:186
uint8_t msr_fs
Definition: libmsr.h:122
struct msr_model msr_model_t
Represents the MSR's model.
int msr_reset(int fd)
Reset the MSR device.
Definition: msr206.c:377
int msr_serial_write(int fd, void *buf, size_t len)
Write a series of bytes to the MSR device.
Definition: serialio.c:59
struct msr_end msr_end_t
Represents the end of a read/write command.
uint8_t msr_tk_len
Definition: libmsr.h:411
struct msr_track msr_track_t
Represents a single track on a magnetic card.
int msr_reverse_track(msr_track_t *track)
Reverse a msr_track_t structure in-place.
Definition: libmsr.c:144
int msr_commtest(int fd)
Perform a communications test.
Definition: msr206.c:81
int msr_set_bpc(int fd, uint8_t bpc1, uint8_t bpc2, uint8_t bpc3)
Set the MSR device's BPC value for each track.
Definition: msr206.c:581
int msr_iso_read(int fd, msr_tracks_t *tracks)
Read an ISO formatted card.
Definition: msr206.c:388
int msr_set_lo_co(int fd)
Set the device's coercivity to low.
Definition: msr206.c:353
void msr_pretty_printer_bits(msr_tracks_t tracks)
Dump a "pretty" binary representation of tracks to stdout.
Definition: libmsr.c:221
int msr_flash_led(int fd, uint8_t led)
Toggle the LEDs on the MSR device.
Definition: msr206.c:160
int msr_serial_close(int fd)
Close a serial connection to the MSR device.
Definition: serialio.c:140
#define MSR_MAX_TRACK_LEN
Definition: libmsr.h:36
struct msr_bpc msr_bpc_t
Represents the MSR's BPC settings for each track.
int msr_zeros(int fd, msr_lz_t *lz)
Get the MSR device's current leading-zero setting.
Definition: msr206.c:23
Represents the MSR's model.
Definition: libmsr.h:286
Represents a command issued to the MSR device.
Definition: libmsr.h:71
Represents a single track on a magnetic card.
Definition: libmsr.h:409
int msr_ram_test(int fd)
Check the device's RAM.
Definition: msr206.c:289
uint8_t msr_esc
Definition: libmsr.h:123
uint8_t msr_bpctk1
Definition: libmsr.h:321
struct msr_cmd msr_cmd_t
Represents a command issued to the MSR device.
int msr_sensor_test(int fd)
Check the device's sensor.
Definition: msr206.c:266
struct msr_lz msr_lz_t
Represents leading zero counts on a card.
void msr_pretty_printer_hex(msr_tracks_t tracks)
Dump a "pretty" hexadecimal representation of tracks to stdout.
Definition: libmsr.c:209
uint8_t msr_model
Definition: libmsr.h:288
uint8_t msr_esc
Definition: libmsr.h:72
int msr_raw_read(int fd, msr_tracks_t *tracks)
Read raw data from a card.
Definition: msr206.c:480
void msr_pretty_output_hex(int fd, msr_tracks_t tracks)
Dump a "pretty" hexadecimal representation of tracks to a fd.
Definition: libmsr.c:172
uint8_t msr_cmd
Definition: libmsr.h:73
Represents the end of a read/write command.
Definition: libmsr.h:120
int msr_model(int fd, uint8_t *buf)
Check the device's model.
Definition: msr206.c:138
int msr_init(int fd)
Initialize the MSR device.
Definition: msr206.c:546
int msr_raw_write(int fd, msr_tracks_t *tracks)
Write raw data to a card.
Definition: msr206.c:513
int msr_serial_open(char *path, int *fd, int blocking, speed_t baud)
Open a serial connection to the MSR device.
Definition: serialio.c:120
int msr_get_co(int fd)
Get the device's coercivity level.
Definition: msr206.c:309
void msr_pretty_printer_string(msr_tracks_t tracks)
Dump a "pretty" string representation of tracks to stdout.
Definition: libmsr.c:215
uint8_t msr_bpctk3
Definition: libmsr.h:323
Represents leading zero counts on a card.
Definition: libmsr.h:196