#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <usb.h>
+#include <unistd.h>
-#include "usbtmc.h"
+#include "scope.h"
#include "commands.h"
static int send_binary(int s, char *buf, int len)
return send_binary(s, buf, strlen(buf));
}
-static void serve_index(int s)
+static void serve_index(int s, struct scope *sc)
{
send_text(s, "HTTP/1.0 200 OK");
send_text(s, "Content-type: text/html\n\n");
- send_text(s, "<html><head><title>Rigol DS1000</title></head><body bgcolor=\"#ffffff\" text=\"#000000\">\n");
+ send_text(s, "<html><head><title>");
+ send_text(s, scope_idn(sc));
+ send_text(s, "</title></head><body bgcolor=\"#ffffff\" text=\"#000000\">\n");
send_text(s, "<img src=\"/lcd.png\" height=\"234\" width=\"320\">\n");
send_text(s, "</body></html>\n");
}
-static void serve_lcd(int s, struct usb_dev_handle *sc)
+static void serve_lcd(int s, struct scope *sc)
{
char buf[256];
int imglen;
unsigned char *png;
- usbtmc_claim(sc);
+ claimscope(sc);
png = get_lcd(sc, &imglen, 0);
- usbtmc_release(sc);
+ releasescope(sc);
if (png == NULL)
return;
free(png);
}
-static void parse_request(int s, struct usb_dev_handle *sc)
+static void parse_request(int s, struct scope *sc)
{
int ret;
char buf[1024];
} while(token != NULL);
if (strcmp("/", file) == 0) {
- serve_index(s);
+ serve_index(s, sc);
} else if (strcmp("/lcd.png", file) == 0) {
serve_lcd(s, sc);
}
int sock, csock;
int opt;
socklen_t slen;
- struct usb_dev_handle *sc;
+ struct scope *sc;
struct sockaddr_in sin, clientsin;
unsigned short port = 8088;
- sc = usbtmc_initscope();
+ sc = initscope();
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
close(csock);
}
- usbtmc_close(sc);
+ closescope(sc);
return 0;
}