enable remote communication

add the correct constant for RESTART-IGNORE TIME.

re-enable opengles2
This commit is contained in:
Zack Buhman 2024-06-27 15:17:57 -05:00
parent 8c1c1e97f6
commit 060fea6cf8
4 changed files with 34 additions and 13 deletions

View File

@ -77,7 +77,7 @@ int min(int a, int b) {
bool is_timer_resume(uint8_t const * const buf, int length)
{
const char * s = "RESUME";
const char * s = "^ RESTART-IGNORE TIME ^";
size_t len = strlen(s);
return (len == length) && (strncmp((const char *)buf, s, length) == 0);
}
@ -85,6 +85,13 @@ bool is_timer_resume(uint8_t const * const buf, int length)
uint32_t handle_line(uint8_t const * const buf, int length,
struct timer_state * timer_state)
{
/*
printf("handle_line: ");
for (int i = 0; i < length; i++) {
printf("%02x ", buf[i]);
}
*/
printf("\n");
if (length == 0) {
timer_state->status = TIMER_RUNNING;
int ret = clock_gettime(CLOCK_MONOTONIC_RAW, &timer_state->counter.start);

View File

@ -22,10 +22,14 @@
#include "ping_pong.h"
#include "gpio.h"
#define DEST_PORT 1234
#define DEST_ADDR "fd00::1"
#define PORT 4321
//#define SERIALPORT "/dev/ttyS0"
#define SERIALPORT "/dev/ttyS0"
//#define SERIALPORT "/dev/ttyUSB0"
#define SERIALPORT "foo.fifo"
//#define SERIALPORT "foo.fifo"
int handle_buf(int sockfd,
struct sockaddr_in6 * dest_addr,
@ -332,12 +336,11 @@ int main(void)
perror("open: serialport");
return -1;
}
/*
ret = set_terminal_attributes(serialfd);
if (ret == -1) {
return -1;
}
*/
{
struct epoll_event ev;
@ -352,8 +355,8 @@ int main(void)
struct sockaddr_in6 dest_addr;
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(1234);
ret = inet_pton(AF_INET6, "::1", &dest_addr.sin6_addr);
dest_addr.sin6_port = htons(DEST_PORT);
ret = inet_pton(AF_INET6, DEST_ADDR, &dest_addr.sin6_addr);
assert(ret == 1);
struct parser_state parser_state = {0};

8
sync.sh Normal file
View File

@ -0,0 +1,8 @@
set -eux
cd /home/bilbo/timer
make clean
rsync -arv --delete /home/bilbo/timer '[fd00::1]':/home/bilbo
rsync -arv --delete /home/bilbo/timer '[fd00::2]':/home/bilbo

View File

@ -19,6 +19,11 @@
#include "ping_pong.h"
#include "gpio.h"
#define DEST_PORT 4321
#define DEST_ADDR "fd00::2"
#define PORT 1234
struct glyph {
int32_t width;
int32_t height;
@ -110,7 +115,7 @@ int load_font(SDL_Renderer * renderer, int font_size)
return -1;
}
error = FT_New_Face(library, "DejaVuSansMono.ttf", 0, &face);
error = FT_New_Face(library, "/home/bilbo/timer/DejaVuSansMono.ttf", 0, &face);
if (error) {
printf("FT_New_Face\n");
return -1;
@ -163,8 +168,6 @@ int max(int a, int b) {
return a > b ? a : b;
}
#define PORT 1234
int handle_buf(int sockfd,
struct sockaddr_in6 * dest_addr,
void * buf, ssize_t length,
@ -326,7 +329,7 @@ int main()
const char * s = SDL_GetRenderDriver(i);
printf(" %s\n", s);
}
renderer = SDL_CreateRenderer(window, "software");
renderer = SDL_CreateRenderer(window, "opengles2");
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_PropertiesID props = SDL_GetRendererProperties(renderer);
@ -373,8 +376,8 @@ int main()
struct sockaddr_in6 dest_addr;
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(4321);
ret = inet_pton(AF_INET6, "::1", &dest_addr.sin6_addr);
dest_addr.sin6_port = htons(DEST_PORT);
ret = inet_pton(AF_INET6, DEST_ADDR, &dest_addr.sin6_addr);
assert(ret == 1);
struct timer_state timer_state = {0};