Make src/link.c actually compile

This commit is contained in:
XANTRONIX Development 2016-05-28 19:07:14 -05:00
parent 382804397c
commit 0cbbc4e8b8
2 changed files with 9 additions and 7 deletions

View file

@ -1,6 +1,7 @@
#ifndef _TABBY_LINK_H
#define _TABBY_LINK_H
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
@ -10,15 +11,15 @@
#include <tabby/clock.h>
#define TABBY_LINK_BAUD B115200
#define TABBY_LINK_BAUD B57600
int tabby_link_open(const char *dev);
int tabby_link_close(int fd);
ssize_t tabby_link_send(int fd, char *buf, uint16_t len);
ssize_t tabby_link_send(int fd, void *buf, uint16_t len);
ssize_t tabby_link_recv(int fd, char *buf, uint16_t len);
ssize_t tabby_link_recv(int fd, void *buf, uint16_t len);
int tabby_link_set_clock_source(int fd, tabby_clock_source source);

View file

@ -1,10 +1,11 @@
#include <tabby/link.h>
#include <tabby/command.h>
int tabby_link_open(const char *dev) {
int fd;
struct termios attr;
if ((fd = open(device, O_RDWR | O_NOCTTY)) < 0) {
if ((fd = open(dev, O_RDWR | O_NOCTTY)) < 0) {
goto error_open;
}
@ -39,9 +40,9 @@ int tabby_link_close(int fd) {
return close(fd);
}
ssize_t tabby_link_send(int fd, char *buf, uint16_t len) {
ssize_t tabby_link_send(int fd, void *buf, uint16_t len) {
uint8_t header[3] = {
TABBY_COMMAND_SEND, len & 0xff00 >> 8, len & 0xff
TABBY_COMMAND_SEND, (len & 0xff00) >> 8, len & 0xff
};
if (write(fd, &header, sizeof(header)) < 0) {
@ -54,7 +55,7 @@ error_write_header:
return -1;
}
ssize_t tabby_link_recv(int fd, char *buf, uint16_t len) {
ssize_t tabby_link_recv(int fd, void *buf, uint16_t len) {
return read(fd, buf, (size_t)len);
}