//-------------------------------------------------------------- void ofxEtherdream::init() { cout << "ETHERDREAM INIT -----------------------------------------------" << endl; int device_num = etherdream_dac_count(); cout << "FOUND " << device_num << " DEVICE(S)" << endl; if (!device_num) { ofLogWarning() << "ofxEtherdream::init - No DACs found"; state = ETHERDREAM_CONNECTION_FAILED; return 0; } for (int i=0; i<device_num; i++) { ofLogNotice() << "ofxEtherdream::init - " << i << " Ether Dream " << etherdream_get_id(etherdream_get(i)); } device = etherdream_get(0); ofLogNotice() << "ofxEtherdream::init - Connecting..."; if (etherdream_connect(device) < 0) { state = ETHERDREAM_CONNECTION_FAILED; return 1; } ofLogNotice() << "ofxEtherdream::init - done"; state = ETHERDREAM_RUNNING; }
int main(int argc, char **argv) { etherdream_lib_start(); /* Sleep for a bit over a second, to ensure that we see broadcasts * from all available DACs. */ usleep(1200000); int cc = etherdream_dac_count(); if (!cc) { printf("No DACs found.\n"); return 0; } int mode; if (argc > 1) mode = atoi(argv[1]); else mode = 0; int i; for (i = 0; i < cc; i++) { printf("%d: Ether Dream %06lx\n", i, etherdream_get_id(etherdream_get(i))); } struct etherdream *d = etherdream_get(0); printf("Connecting...\n"); if (etherdream_connect(d) < 0) return 1; i = 0; while (1) { fill_circle((float)i / 50, mode); int res = etherdream_write(d, circle, CIRCLE_POINTS, 30000, 1); if (res != 0) { printf("write %d\n", res); } etherdream_wait_for_ready(d); i++; } printf("done\n"); return 0; }
DACList EtherDream::list_dacs() { int total = etherdream_dac_count(); DACList dacs(total); for(int i = 0; i < total; i++) { struct etherdream* dac = etherdream_get(i); unsigned long id = etherdream_get_id(dac); std::stringstream name; name << PREFIX_ETHERDREAM; name << std::setfill('0') << std::setw(6) << std::hex << id; dacs[i] = name.str(); } return dacs; }