summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-05-01 21:58:53 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-05-01 21:58:53 -0400
commit09637273dedf8fc266678a1841146a7046e21548 (patch)
tree6f51fd61bbb7669f851721d88fbb1862936f6da6
parent92b72179b0e81413a8a77106ff0fc28eed3aaade (diff)
Test clientHEADmain
-rw-r--r--.gitignore1
-rw-r--r--Makefile21
-rw-r--r--build/artifacts/main.obin0 -> 2144 bytes
-rwxr-xr-xbuild/osm-interplaydbin0 -> 20608 bytes
-rw-r--r--src/main.c35
5 files changed, 57 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..14ab9b5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+
+SRC_DIR = src
+BUILD_DIR = build
+OBJ_DIR = $(BUILD_DIR)/artifacts
+INCLUDE_DIR = ./include
+
+SRCS = $(notdir $(wildcard $(SRC_DIR)/*.c))
+OBJS = $(addsuffix .o, $(basename $(SRCS)))
+
+CFLAGS ?= -Werror -Wall
+
+build: build_dir $(OBJS)
+ $(CC) -lopensmarts -o $(BUILD_DIR)/osm-interplayd $(addprefix $(OBJ_DIR)/, $(OBJS))
+
+%.o: $(SRC_DIR)/%.c
+ $(CC) $(CFLAGS) -c -I$(INCLUDE_DIR) -o $(BUILD_DIR)/artifacts/$@ $<
+
+build_dir:
+ mkdir -p $(BUILD_DIR)
+ mkdir -p $(OBJ_DIR)
+
diff --git a/build/artifacts/main.o b/build/artifacts/main.o
new file mode 100644
index 0000000..e49ffdb
--- /dev/null
+++ b/build/artifacts/main.o
Binary files differ
diff --git a/build/osm-interplayd b/build/osm-interplayd
new file mode 100755
index 0000000..fba6f0f
--- /dev/null
+++ b/build/osm-interplayd
Binary files differ
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..d929499
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,35 @@
+#include <osm/discover.h>
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ // connect to socket
+ int fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
+ struct sockaddr_un addr = {0};
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, "/run/osm/onboard/0");
+
+ int ret = connect(fd, (struct sockaddr *) &addr, sizeof(addr));
+ if (ret == -1)
+ {
+ perror("connect");
+ return 1;
+ }
+
+ double temp = 0;
+ read(fd, &temp, sizeof(temp));
+
+ close(fd);
+
+ printf("%f\n", temp);
+
+ return 0;
+}
+
+