int main(int argc, char **argv) { FILE *input; FILE *output; enum headset_type type; char raw_frame[32]; struct epoc_frame frame; if (argc < 3) { fputs("Missing argument\nExpected: decrypt_emotiv [consumer|research] source [dest]\n", stderr); fputs("By default, dest = stdout\n", stderr); return 1; } if(strcmp(argv[1], "research") == 0) type = RESEARCH_HEADSET; else type = CONSUMER_HEADSET; input = fopen(argv[2], "rb"); printf("source: %s\n",argv[2]); if (input == NULL) { fputs("File read error: couldn't open the EEG source!", stderr); return 1; } if (argc == 3) { output = stdout; } else { output = fopen(argv[3], "wb"); printf("destination: %s\n",argv[3]); if (output == NULL) { fputs("File write error: couldn't open the destination file for uncrypted data", stderr); return 1; } } epoc_init(input,output, type); while ( 1 ) { epoc_get_next_frame(&frame); printf("%d %d %d %d %d\n", frame.gyroX, frame.gyroY, frame.F3, frame.FC6, frame.P7); fflush(stdout); } epoc_close(); return 0; }
int main(int argc, char **argv) { FILE *input; FILE *output; enum headset_type type; char raw_frame[32]; struct epoc_frame frame; epoc_device* d; char data[32]; if (argc < 2) { fputs("Missing argument\nExpected: epocd [consumer|research|special]\n", stderr); return 1; } if(strcmp(argv[1], "research") == 0) type = RESEARCH_HEADSET; else if(strcmp(argv[1], "consumer") == 0) type = CONSUMER_HEADSET; else if(strcmp(argv[1], "special") == 0) type = SPECIAL_HEADSET; else { fputs("Bad headset type argument\nExpected: epocd [consumer|research|special] source [dest]\n", stderr); return 1; } epoc_init(type); d = epoc_create(); printf("Current epoc devices connected: %d\n", epoc_get_count(d, EPOC_VID, EPOC_PID)); if(epoc_open(d, EPOC_VID, EPOC_PID, 0) != 0) { printf("CANNOT CONNECT\n"); return 1; } while(1) { if(epoc_read_data(d, data) > 0) { epoc_get_next_frame(&frame, data); printf("%d %d %d %d %d\n", frame.gyroX, frame.gyroY, frame.F3, frame.FC6, frame.P7); fflush(stdout); } } epoc_close(d); epoc_delete(d); return 0; }
int main(int argc, char **argv) { FILE *output = stdout; enum headset_type type = RESEARCH_HEADSET; char raw_frame[32]; struct epoc_frame frame; int source_index = 0, count_devs, c; opterr = 0; while ((c = getopt (argc, argv, "t:n:o:")) != -1) switch (c) { case 't': if(optarg[0] == 'r') type = RESEARCH_HEADSET; else if(optarg[0] == 'c') type = CONSUMER_HEADSET; break; case 'n': source_index = atoi(optarg); break; case 'o': output = fopen(optarg, "wb"); if (output == NULL) { fputs("File write error: couldn't open the destination file for uncrypted data\n", stderr); return 1; } break; default: fputs("Bad arguments\n", stderr); return 1; } if((count_devs = epoc_get_count(EPOC_VID, EPOC_PID)) <= source_index){ fprintf(stderr, "Cannot find device with vid: %d; pid: %d\n", EPOC_VID, EPOC_PID); return 1; } printf("Found %d devices\n", count_devs); epoc_device *device = epoc_open(EPOC_VID, EPOC_PID, source_index); if(device == NULL) { fprintf(stderr, "Cannot open the device %d\n", source_index); return 1; } printf("Device %d opened...\n", source_index); epoc_handler *eh = epoc_init(device, type); if(eh == NULL) { fprintf(stderr, "Cannot init the device!\n"); epoc_close(device); return 1; } printf("Device %d inited...\nReading...\n", source_index); while ( 1 ) { int i; epoc_get_next_frame(eh, &frame); fprintf(output, "%d %d %d", frame.counter, frame.gyro.X, frame.gyro.Y); for(i=0; i < 16; ++i) fprintf(output, " %d", frame.electrode[i]); fprintf(output, "\n"); fflush(output); } epoc_deinit(eh); epoc_close(device); return 0; }
int main(int argc, char* argv[]) { signal(SIGINT, sigproc); #ifndef WIN32 signal(SIGQUIT, sigproc); #endif UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) ); char buffer[OUTPUT_BUFFER_SIZE]; FILE *input; FILE *output; enum headset_type type; char raw_frame[32]; struct epoc_frame frame; epoc_device* d; uint8_t data[32]; if (argc < 2) { fputs("Missing argument\nExpected: epocd [consumer|research|special]\n", stderr); return 1; } if(strcmp(argv[1], "research") == 0) type = RESEARCH_HEADSET; else if(strcmp(argv[1], "consumer") == 0) type = CONSUMER_HEADSET; else if(strcmp(argv[1], "special") == 0) type = SPECIAL_HEADSET; else { fputs("Bad headset type argument\nExpected: epocd [consumer|research|special] source [dest]\n", stderr); return 1; } epoc_init(type); d = epoc_create(); printf("Current epoc devices connected: %d\n", epoc_get_count(d, EPOC_VID, EPOC_PID)); if(epoc_open(d, EPOC_VID, EPOC_PID, 0) != 0) { printf("CANNOT CONNECT\n"); return 1; } while(1) { if(epoc_read_data(d, data) > 0) { epoc_get_next_frame(&frame, data); osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE ); p << osc::BeginBundleImmediate << osc::BeginMessage( "/epoc/channels" ) << frame.F3 << frame.FC6 << frame.P7 << frame.T8 << frame.F7 << frame.F8 << frame.T7 << frame.P8 << frame.AF4 << frame.F4 << frame.AF3 << frame.O2 << frame.O1 << frame.FC5 << osc::EndMessage << osc::BeginMessage( "/epoc/gyro" ) << frame.gyroX << frame.gyroY << osc::EndMessage << osc::EndBundle; transmitSocket.Send( p.Data(), p.Size() ); } } epoc_close(d); epoc_delete(d); return 0; }