File tree Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -304,6 +304,7 @@ dai_add_example(script_http_server Script/script_http_server.cpp OFF)
304304dai_add_example(script_mjpeg_server Script/script_mjpeg_server.cpp OFF )
305305dai_add_example(script_nndata_example Script/script_nndata_example.cpp ON )
306306dai_add_example(script_json_communication Script/script_json_communication.cpp ON )
307+ dai_add_example(script_get_device_info Script/script_get_device_info.cpp ON )
307308
308309# SpatialDetection
309310dai_add_example(spatial_location_calculator SpatialDetection/spatial_location_calculator.cpp ON )
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+
3+ // Includes common necessary includes for development using depthai library
4+ #include " depthai/depthai.hpp"
5+
6+ int main () {
7+ using namespace std ;
8+
9+ // Start defining a pipeline
10+ dai::Pipeline pipeline;
11+
12+ // Script node
13+ auto script = pipeline.create <dai::node::Script>();
14+ script->setScript (R"(
15+ import json
16+ data = json.dumps({
17+ 'deviceId': __device_id__,
18+ 'fwVersion': __version__
19+ }).encode('utf-8')
20+
21+ b = Buffer(len(data))
22+ b.setData(data)
23+ node.io['info'].send(b)
24+ )" );
25+
26+ // XLinkOut
27+ auto xout = pipeline.create <dai::node::XLinkOut>();
28+ xout->setStreamName (" info" );
29+ script->outputs [" info" ].link (xout->input );
30+
31+ // Connect to device with pipeline
32+ dai::Device device (pipeline);
33+ auto msg = device.getOutputQueue (" info" )->get <dai::Buffer>();
34+ auto data = nlohmann::json::parse (msg->getData ());
35+ std::cout << data.dump (4 ) << std::endl;
36+
37+ return 0 ;
38+ }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ int main() {
2727
2828 ip = get_ip_address('re0') # '192.168.0.110'
2929 node.warn(f'IP of the device: {ip}')
30- node.io['end'].send(Buffer())
30+ node.io['end'].send(Buffer(32 ))
3131 )" );
3232
3333 // XLinkOut
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ int main() {
2424 data1 = r1.read()
2525 node.warn(f'Public IP: {data1}')
2626
27- node.io['end'].send(Buffer())
27+ node.io['end'].send(Buffer(32 ))
2828 )" );
2929
3030 // XLinkOut
Original file line number Diff line number Diff line change @@ -29,10 +29,8 @@ int main() {
2929 # Change initial dictionary a bit
3030 dict['one'] += 1
3131 dict['foo'] = "baz"
32- dict['fw_version'] = __version__
33- dict['device_id'] = __device_id__
3432
35- b = Buffer(256 )
33+ b = Buffer(30 )
3634 b.setData(json.dumps(dict).encode('utf-8'))
3735 node.io['out'].send(b)
3836 )" );
You can’t perform that action at this time.
0 commit comments