Make src/link.c actually compile
This commit is contained in:
parent
382804397c
commit
0cbbc4e8b8
2 changed files with 9 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _TABBY_LINK_H
|
#ifndef _TABBY_LINK_H
|
||||||
#define _TABBY_LINK_H
|
#define _TABBY_LINK_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -10,15 +11,15 @@
|
||||||
|
|
||||||
#include <tabby/clock.h>
|
#include <tabby/clock.h>
|
||||||
|
|
||||||
#define TABBY_LINK_BAUD B115200
|
#define TABBY_LINK_BAUD B57600
|
||||||
|
|
||||||
int tabby_link_open(const char *dev);
|
int tabby_link_open(const char *dev);
|
||||||
|
|
||||||
int tabby_link_close(int fd);
|
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);
|
int tabby_link_set_clock_source(int fd, tabby_clock_source source);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include <tabby/link.h>
|
#include <tabby/link.h>
|
||||||
|
#include <tabby/command.h>
|
||||||
|
|
||||||
int tabby_link_open(const char *dev) {
|
int tabby_link_open(const char *dev) {
|
||||||
int fd;
|
int fd;
|
||||||
struct termios attr;
|
struct termios attr;
|
||||||
|
|
||||||
if ((fd = open(device, O_RDWR | O_NOCTTY)) < 0) {
|
if ((fd = open(dev, O_RDWR | O_NOCTTY)) < 0) {
|
||||||
goto error_open;
|
goto error_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ int tabby_link_close(int fd) {
|
||||||
return close(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] = {
|
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) {
|
if (write(fd, &header, sizeof(header)) < 0) {
|
||||||
|
@ -54,7 +55,7 @@ error_write_header:
|
||||||
return -1;
|
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);
|
return read(fd, buf, (size_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue