API
 
Loading...
Searching...
No Matches
configusbhub.cpp
Go to the documentation of this file.
1
2#include <iostream>
3#include "BrainStem2/BrainStem-all.h"
4
5/*==========================================================================================================================*/
6/* Simple program to configure an Acroname USB 3 programmable hub for MagAO-X
7 *
8 * Does the following:
9 * 1) Reads model, version, and serial number (you need serial number for configuration of the app)
10 * 2) Turns off all USB ports
11 * 3) Saves the all-ports-off state so that the unit will start up off.
12 *
13 * Compile with:
14 * $ g++ -o configusbhub configusbhub.cpp -I../../../libs/BrainStem2/ ../../../libs/BrainStem2/libBrainStem2.a -lpthread
15 *
16 * Run with:
17 * $ sudo ./configusbhub
18 */
19/*==========================================================================================================================*/
20int main()
21{
22
23 aUSBHub3p hub; // BrainStem library handle
24
25 aErr err = aErrNone;
26
27
28 err = hub.discoverAndConnect(USB);
29
30 if(err != aErrNone)
31 {
32 std::cerr << "No hub found.\n";
33 return -1;
34 }
35
36 SystemClass sys;
37 sys.init(&hub,0);
38
39 uint8_t model;
40 sys.getModel(&model);
41
42 uint32_t version;
43 sys.getVersion(&version);
44 std::cout << version << "\n";
45 std::cout << "Version: " << aVersion_ParseMajor(version) << "." << aVersion_ParseMinor(version) << "." << aVersion_ParsePatch(version) << "\n";
46 uint32_t serial;
47 sys.getSerialNumber(&serial);
48
49 std::cout << "Serial Number: " << serial << "\n";
50
51 for(int n=0;n<8;++n)
52 {
53 hub.usb.setPortDisable(n);
54 }
55
56 sys.save();
57
58 hub.disconnect();
59
60}
int main()