mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Attempt to capture rollover events --- don't think it works. Add a basic
command processor.
This commit is contained in:
@@ -516,27 +516,27 @@
|
||||
<CyGuid_ebc4f06d-207f-49c2-a540-72acf4adabc0 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFolderSerialize" version="3">
|
||||
<CyGuid_2f73275c-45bf-46ba-b3b1-00a2fe0c8dd8 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtBaseContainerSerialize" version="1">
|
||||
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemSerialize" version="2" name="LED" persistent="">
|
||||
<Hidden v="False" />
|
||||
<Hidden v="True" />
|
||||
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
|
||||
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemListSerialize" version="2">
|
||||
<dependencies>
|
||||
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileSerialize" version="3" xml_contents_version="1">
|
||||
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemSerialize" version="2" name="LED_aliases.h" persistent="Generated_Source\PSoC5\LED_aliases.h">
|
||||
<Hidden v="False" />
|
||||
<Hidden v="True" />
|
||||
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
|
||||
<build_action v="HEADER;;;;" />
|
||||
<PropertyDeltas />
|
||||
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
|
||||
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileSerialize" version="3" xml_contents_version="1">
|
||||
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemSerialize" version="2" name="LED.c" persistent="Generated_Source\PSoC5\LED.c">
|
||||
<Hidden v="False" />
|
||||
<Hidden v="True" />
|
||||
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
|
||||
<build_action v="SOURCE_C;CortexM3;;;" />
|
||||
<PropertyDeltas />
|
||||
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
|
||||
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileSerialize" version="3" xml_contents_version="1">
|
||||
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemSerialize" version="2" name="LED.h" persistent="Generated_Source\PSoC5\LED.h">
|
||||
<Hidden v="False" />
|
||||
<Hidden v="True" />
|
||||
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
|
||||
<build_action v="HEADER;;;;" />
|
||||
<PropertyDeltas />
|
||||
|
||||
Binary file not shown.
@@ -171,7 +171,7 @@ static void cmd_bulk_test(struct any_frame* f)
|
||||
uint8_t buffer[64];
|
||||
|
||||
wait_until_writeable(FLUXENGINE_DATA_IN_EP_NUM);
|
||||
for (int x=0; x<16; x++)
|
||||
for (int x=0; x<64; x++)
|
||||
for (int y=0; y<256; y++)
|
||||
{
|
||||
for (unsigned z=0; z<sizeof(buffer); z++)
|
||||
|
||||
7
Makefile
7
Makefile
@@ -1,7 +1,12 @@
|
||||
CFLAGS = -g -Wall $(shell pkg-config --cflags libusb-1.0)
|
||||
LDFLAGS = -g $(shell pkg-config --libs libusb-1.0)
|
||||
|
||||
SRCS = main.c usb.c
|
||||
SRCS = \
|
||||
main.c \
|
||||
usb.c \
|
||||
cmd_rpm.c \
|
||||
cmd_usbbench.c
|
||||
|
||||
OBJS = $(patsubst %.c, .objs/%.o, $(SRCS))
|
||||
|
||||
fluxclient: $(OBJS) Makefile
|
||||
|
||||
16
cmd_rpm.c
Normal file
16
cmd_rpm.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "globals.h"
|
||||
|
||||
static void syntax_error(void)
|
||||
{
|
||||
fprintf(stderr, "syntax: fluxclient rpm\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void cmd_rpm(char* const* argv)
|
||||
{
|
||||
if (countargs(argv) != 1)
|
||||
syntax_error();
|
||||
|
||||
int period_ms = usb_measure_speed();
|
||||
printf("Rotational period is %d ms (%f rpm)\n", period_ms, 60000.0/period_ms);
|
||||
}
|
||||
16
cmd_usbbench.c
Normal file
16
cmd_usbbench.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "globals.h"
|
||||
|
||||
static void syntax_error(void)
|
||||
{
|
||||
fprintf(stderr, "syntax: fluxclient usbbench\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void cmd_usbbench(char* const* argv)
|
||||
{
|
||||
if (countargs(argv) != 1)
|
||||
syntax_error();
|
||||
|
||||
usb_bulk_test();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
extern void error(const char* message, ...);
|
||||
extern double gettime(void);
|
||||
extern int countargs(char* const* argv);
|
||||
|
||||
extern void usb_init(void);
|
||||
extern void usb_cmd_send(void* ptr, int len);
|
||||
@@ -25,4 +26,7 @@ extern int usb_measure_speed(void);
|
||||
extern void usb_bulk_test(void);
|
||||
extern void usb_read(int side);
|
||||
|
||||
extern void cmd_rpm(char* const* argv);
|
||||
extern void cmd_usbbench(char* const* argv);
|
||||
|
||||
#endif
|
||||
|
||||
60
main.c
60
main.c
@@ -23,58 +23,58 @@ double gettime(void)
|
||||
return (double)tv.tv_sec + tv.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
static void parse_options(int argc, char* const* argv)
|
||||
int countargs(char* const* argv)
|
||||
{
|
||||
int count = 0;
|
||||
while (*argv++)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
void syntax_error(void)
|
||||
{
|
||||
error("syntax error (try -h for help)");
|
||||
}
|
||||
|
||||
static char* const* parse_global_options(char* const* argv)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
switch (getopt(argc, argv, "ht:"))
|
||||
switch (getopt(countargs(argv), argv, "+ht:"))
|
||||
{
|
||||
case -1:
|
||||
return;
|
||||
return argv + optind;
|
||||
|
||||
case 'h':
|
||||
error("sorry, no help yet");
|
||||
|
||||
default:
|
||||
error("syntax error (try -h for help)");
|
||||
syntax_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* const* argv)
|
||||
{
|
||||
argv = parse_global_options(argv);
|
||||
usb_init();
|
||||
|
||||
int v = usb_get_version();
|
||||
printf("FluxEngine version %d\n", v);
|
||||
/* Just check that a FluxEngine is plugged in. */
|
||||
|
||||
int period_ms = usb_measure_speed();
|
||||
printf("Rotational period is %d ms (%f rpm)\n", period_ms, 60000.0/period_ms);
|
||||
(void) usb_get_version();
|
||||
|
||||
usb_seek(20);
|
||||
usb_read(0);
|
||||
//usb_bulk_test();
|
||||
if (!argv[0])
|
||||
syntax_error();
|
||||
|
||||
#if 0
|
||||
parse_options(argc, argv);
|
||||
if (!serialport)
|
||||
error("you must specify a serial port name");
|
||||
open_serial_port(serialport);
|
||||
if (strcmp(argv[0], "rpm") == 0)
|
||||
cmd_rpm(argv);
|
||||
else if (strcmp(argv[0], "usbbench") == 0)
|
||||
cmd_usbbench(argv);
|
||||
else
|
||||
syntax_error();
|
||||
|
||||
const int iterations = 10000;
|
||||
double starttime = gettime();
|
||||
for (int i=0; i<iterations; i++)
|
||||
{
|
||||
frame_t frame;
|
||||
read_frame(&frame);
|
||||
}
|
||||
double endtime = gettime();
|
||||
int transferred = iterations*sizeof(frame_t);
|
||||
printf("amount transferred: %d bytes\n", transferred);
|
||||
double elapsedtime = endtime - starttime;
|
||||
printf("elapsed time: %f seconds\n", elapsedtime);
|
||||
printf("performance: %f kB/s\n", (transferred/1024) / elapsedtime);
|
||||
#endif
|
||||
// usb_seek(20);
|
||||
// usb_read(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
4
usb.c
4
usb.c
@@ -114,7 +114,7 @@ void usb_bulk_test(void)
|
||||
struct any_frame f = { .f = {.type = F_FRAME_BULK_TEST_CMD, .size = sizeof(f)} };
|
||||
usb_cmd_send(&f, f.f.size);
|
||||
|
||||
uint8_t bulk_buffer[16*256*64];
|
||||
uint8_t bulk_buffer[64*256*64];
|
||||
int total_len = sizeof(bulk_buffer);
|
||||
double start_time = gettime();
|
||||
large_bulk_transfer(FLUXENGINE_DATA_IN_EP, bulk_buffer, total_len);
|
||||
@@ -123,7 +123,7 @@ void usb_bulk_test(void)
|
||||
printf("Transferred %d bytes in %d ms (%d kB/s)\n",
|
||||
total_len, (int)(elapsed_time * 1000.0),
|
||||
(int)((total_len / 1024.0) / elapsed_time));
|
||||
for (int x=0; x<16; x++)
|
||||
for (int x=0; x<64; x++)
|
||||
for (int y=0; y<256; y++)
|
||||
for (int z=0; z<64; z++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user