Am 14.05.2017 um 02:42 schrieb John Bradley via Qemu-devel:
From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001
From: John Bradley <fly...@rocketmail.com>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files.
Addition of PanelEmu
The files add the ability to attach, via TCP, a panel emulator
The include a unification of several PD Raspberry PI additions
A modification to dev-network to all circle SDK WWW client to work
The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git
Signed-off-by: John Bradley <fly...@rocketmail.com>
---
[ ... snip ... ]
diff --git a/util/PanelEmu.c b/util/PanelEmu.c
new file mode 100644
index 0000000000..59c87d2747
--- /dev/null
+++ b/util/PanelEmu.c
@@ -0,0 +1,293 @@
+/*
+ * Emulation for Rasp PI GPIO via Server connected to via Socket
+ *
+ */
+#include "qemu/osdep.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef __MINGW32__
I think that should be #ifdef _WIN32.
Maybe in the far future QEMU could also be compiled with Visual Studio
or any other windows compiler
+#include <winsock2.h>
+#else
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+
+#include "qemu/PanelEmu.h"
+
+typedef enum
+{
+ MACHINEDESC = 0,
+ PINSTOPANEL = 1,
+ READREQ = 2,
+ PINCOUNT = 3,
+ ENABLEMAP = 4,
+ INPUTMAP = 5,
+ OUTPUTMAP = 6,
+ PINSTOQEMU = 7
+} PacketType;
+
+#define MAXPACKET 255
+
+#define PACKETLEN 0 //Includes Packet Length
+#define PACKETTYPE 1
+
+typedef struct
+{
+ unsigned short int Data[MAXPACKET];
+} CommandPacket;
Why not something like
typedef struct
{
uint8_t len;
uint8_t type;
union {
struct {
uint8_t cnt;
} pinCount;
struct {
uint16_t pin0to15;
uint16_t pin16to31;
uint16_t pin32to47;
uint16_t pin48to63;
} dataUpdate;
/* todo: other packet types */
};
} CommandPacket;
[ ... snip ... ]
+/* Set a pin to a specified value */
+void senddatatopanel(panel_connection_t* h, uint64_t pin, bool val)
+{
+ CommandPacket Pkt;
+
+ Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[6 + 1]-(char *) &Pkt.Data[0];
what's the use of this pointer aritmethic instead of just 6?
Geert