-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardwarex.py
1466 lines (1233 loc) · 64.8 KB
/
hardwarex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import print_function
import ctypes
from ctypes import util
import sys, os
# Load DLL into memory.
is_64bits = sys.maxsize > 2**32
if sys.platform.startswith('win'):
try:
if is_64bits:
#hDll = ctypes.CDLL("x64/hardwarex.dll", winmode=True) # winmode=True necessary since Python 3.8 but not available in previous...
if "add_dll_directory" in dir(os):
os.add_dll_directory(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x64'))
else:
os.environ['PATH'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x64') + ';' + os.environ['PATH']
# Should specify full path instead...? Less interesting if there are other necessary libraries in the folder...
#hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x64/hardwarex.dll'))
else:
#hDll = ctypes.CDLL("x86/hardwarex.dll", winmode=True) # winmode=True necessary since Python 3.8 but not available in previous...
if "add_dll_directory" in dir(os):
os.add_dll_directory(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86'))
else:
os.environ['PATH'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86') + ';' + os.environ['PATH']
# Should specify full path instead...? Less interesting if there are other necessary libraries in the folder...
#hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86/hardwarex.dll'))
hDll = ctypes.CDLL("hardwarex.dll")
except Exception:
try:
hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join('lib', 'hardwarex.dll')))
except Exception:
# Not sure what it does...
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
hDll = ctypes.CDLL(ctypes.util.find_library("hardwarex"))
elif sys.platform.startswith('linux'):
try:
#os.environ['LD_LIBRARY_PATH'] = os.path.dirname(os.path.realpath(__file__)) + ':' + os.environ['LD_LIBRARY_PATH'] # Not taken into account by ctypes when set here (but OK if set before calling python in the terminal)...? See https://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes. Setting rpath using patchelf in the library might help finding other necessary libraries if needed...
hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join('linux_x64', 'hardwarex.so')))
except Exception:
try:
hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join('lib', 'hardwarex.so')))
except Exception:
# Not sure what it does...
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
hDll = ctypes.CDLL(ctypes.util.find_library("hardwarex"))
elif sys.platform.startswith('darwin'):
try:
#os.environ['DYLD_LIBRARY_PATH'] = os.path.dirname(os.path.realpath(__file__)) + ':' + os.environ['DYLD_LIBRARY_PATH'] # Not allowed to change here...?
hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join('mac', 'hardwarex.dylib')))
except Exception:
try:
hDll = ctypes.CDLL(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join('lib', 'hardwarex.dylib')))
except Exception:
# Not sure what it does...
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
hDll = ctypes.CDLL(ctypes.util.find_library("hardwarex"))
else:
# Not sure what it does...
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
hDll = ctypes.CDLL(ctypes.util.find_library("hardwarex"))
class UTC_Time_SBG(ctypes.Structure):
_fields_ = [("Nanoseconds", ctypes.c_uint),
("Year", ctypes.c_ushort),
("Month", ctypes.c_ubyte),
("Day", ctypes.c_ubyte),
("Hour", ctypes.c_ubyte),
("Minute", ctypes.c_ubyte),
("Seconds", ctypes.c_ubyte),
("Valid", ctypes.c_ubyte)]
class SBGDATA(ctypes.Structure):
_fields_ = [("temp", ctypes.c_double),
("accx", ctypes.c_double), ("accy", ctypes.c_double), ("accz", ctypes.c_double),
("gyrx", ctypes.c_double), ("gyry", ctypes.c_double), ("gyrz", ctypes.c_double),
("magx", ctypes.c_double), ("magy", ctypes.c_double), ("magz", ctypes.c_double),
("q0", ctypes.c_double), ("q1", ctypes.c_double), ("q2", ctypes.c_double), ("q3", ctypes.c_double),
("roll", ctypes.c_double), ("pitch", ctypes.c_double), ("yaw", ctypes.c_double),
("a", ctypes.c_double), ("b", ctypes.c_double), ("c", ctypes.c_double),
("d", ctypes.c_double), ("e", ctypes.c_double), ("f", ctypes.c_double),
("g", ctypes.c_double), ("h", ctypes.c_double), ("i", ctypes.c_double),
("Ain_1", ctypes.c_ushort), ("Ain_2", ctypes.c_ushort),
("Lat", ctypes.c_double), ("Long", ctypes.c_double), ("Alt", ctypes.c_double),
("Vel_X", ctypes.c_double), ("Vel_Y", ctypes.c_double), ("Vel_Z", ctypes.c_double),
("eulerStdDev", ctypes.c_float*3),
("positionStdDev", ctypes.c_float*3),
("velocityStdDev", ctypes.c_float*3),
("heave_period", ctypes.c_double),
("surge", ctypes.c_double), ("sway", ctypes.c_double), ("heave", ctypes.c_double),
("surge_accel", ctypes.c_double), ("sway_accel", ctypes.c_double), ("heave_accel", ctypes.c_double),
("surge_vel", ctypes.c_double), ("sway_vel", ctypes.c_double), ("heave_vel", ctypes.c_double),
("odometerVelocity", ctypes.c_double),
("gpsRawData", ctypes.c_ubyte*4086),
("gpsRawDataSize", ctypes.c_uint),
("Status", ctypes.c_ubyte),
("TS", ctypes.c_uint),
("UTCTime", UTC_Time_SBG),
("Roll", ctypes.c_double), ("Pitch", ctypes.c_double), ("Yaw", ctypes.c_double)]
def CreateSBGData():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.POINTER(SBGDATA))
hApiParams = None
function_call = hApiProto(('CreateSBGDatax', hDll), hApiParams)
return function_call()
def DestroySBGData(pSBGData):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.POINTER(SBGDATA))
hApiParams = (1, "pSBGData", 0),
function_call = hApiProto(('DestroySBGDatax', hDll), hApiParams)
function_call(pSBGData)
def CreateSBG():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateSBGx', hDll), hApiParams)
return function_call()
def DestroySBG(pSBG):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pSBG", 0),
function_call = hApiProto(('DestroySBGx', hDll), hApiParams)
function_call(pSBG)
def GetLatestDataSBG(pSBG):
global hDll
pSBGData = (SBGDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(SBGDATA))
hApiParams = (1, "pSBG", 0),(1, "pSBGData", 0),
function_call = hApiProto(('GetLatestDataSBGx', hDll), hApiParams)
res = function_call(pSBG, pSBGData)
return res, pSBGData[0]
def ConnectSBG(pSBG, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pSBG", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectSBGx', hDll), hApiParams)
return function_call(pSBG, cfgFilePath.encode('UTF-8'))
def DisconnectSBG(pSBG):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSBG", 0),
function_call = hApiProto(('DisconnectSBGx', hDll), hApiParams)
return function_call(pSBG)
def GetLatestDataFromThreadSBG(pSBG):
global hDll
pSBGData = (SBGDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(SBGDATA))
hApiParams = (1, "pSBG", 0),(1, "pSBGData", 0),
function_call = hApiProto(('GetLatestDataFromThreadSBGx', hDll), hApiParams)
res = function_call(pSBG, pSBGData)
return res, pSBGData[0]
def StartThreadSBG(pSBG):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSBG", 0),
function_call = hApiProto(('StartThreadSBGx', hDll), hApiParams)
return function_call(pSBG)
def StopThreadSBG(pSBG):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSBG", 0),
function_call = hApiProto(('StopThreadSBGx', hDll), hApiParams)
return function_call(pSBG)
class UTC_Time_MT(ctypes.Structure):
_fields_ = [("Nanoseconds", ctypes.c_uint),
("Year", ctypes.c_ushort),
("Month", ctypes.c_ubyte),
("Day", ctypes.c_ubyte),
("Hour", ctypes.c_ubyte),
("Minute", ctypes.c_ubyte),
("Seconds", ctypes.c_ubyte),
("Valid", ctypes.c_ubyte)]
class MTDATA(ctypes.Structure):
_fields_ = [("temp", ctypes.c_double),
("accx", ctypes.c_double), ("accy", ctypes.c_double), ("accz", ctypes.c_double),
("gyrx", ctypes.c_double), ("gyry", ctypes.c_double), ("gyrz", ctypes.c_double),
("magx", ctypes.c_double), ("magy", ctypes.c_double), ("magz", ctypes.c_double),
("q0", ctypes.c_double), ("q1", ctypes.c_double), ("q2", ctypes.c_double), ("q3", ctypes.c_double),
("roll", ctypes.c_double), ("pitch", ctypes.c_double), ("yaw", ctypes.c_double),
("a", ctypes.c_double), ("b", ctypes.c_double), ("c", ctypes.c_double),
("d", ctypes.c_double), ("e", ctypes.c_double), ("f", ctypes.c_double),
("g", ctypes.c_double), ("h", ctypes.c_double), ("i", ctypes.c_double),
("Ain_1", ctypes.c_ushort), ("Ain_2", ctypes.c_ushort),
("Lat", ctypes.c_double), ("Long", ctypes.c_double), ("Alt", ctypes.c_double),
("Vel_X", ctypes.c_double), ("Vel_Y", ctypes.c_double), ("Vel_Z", ctypes.c_double),
("Status", ctypes.c_ubyte),
("TS", ctypes.c_ushort),
("UTCTime", UTC_Time_MT),
("Roll", ctypes.c_double), ("Pitch", ctypes.c_double), ("Yaw", ctypes.c_double)]
def CreateMTData():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.POINTER(MTDATA))
hApiParams = None
function_call = hApiProto(('CreateMTDatax', hDll), hApiParams)
return function_call()
def DestroyMTData(pMTData):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.POINTER(MTDATA))
hApiParams = (1, "pMTData", 0),
function_call = hApiProto(('DestroyMTDatax', hDll), hApiParams)
function_call(pMTData)
def CreateMT():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateMTx', hDll), hApiParams)
return function_call()
def DestroyMT(pMT):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pMT", 0),
function_call = hApiProto(('DestroyMTx', hDll), hApiParams)
function_call(pMT)
def GetLatestDataMT(pMT):
global hDll
pMTData = (MTDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(MTDATA))
hApiParams = (1, "pMT", 0),(1, "pMTData", 0),
function_call = hApiProto(('GetLatestDataMTx', hDll), hApiParams)
res = function_call(pMT, pMTData)
return res, pMTData[0]
def ConnectMT(pMT, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pMT", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectMTx', hDll), hApiParams)
return function_call(pMT, cfgFilePath.encode('UTF-8'))
def DisconnectMT(pMT):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pMT", 0),
function_call = hApiProto(('DisconnectMTx', hDll), hApiParams)
return function_call(pMT)
def GetLatestDataFromThreadMT(pMT):
global hDll
pMTData = (MTDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(MTDATA))
hApiParams = (1, "pMT", 0),(1, "pMTData", 0),
function_call = hApiProto(('GetLatestDataFromThreadMTx', hDll), hApiParams)
res = function_call(pMT, pMTData)
return res, pMTData[0]
def StartThreadMT(pMT):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pMT", 0),
function_call = hApiProto(('StartThreadMTx', hDll), hApiParams)
return function_call(pMT)
def StopThreadMT(pMT):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pMT", 0),
function_call = hApiProto(('StopThreadMTx', hDll), hApiParams)
return function_call(pMT)
class RAZORAHRSDATA(ctypes.Structure):
_fields_ = [("yaw", ctypes.c_double), ("pitch", ctypes.c_double), ("roll", ctypes.c_double),
("accx", ctypes.c_double), ("accy", ctypes.c_double), ("accz", ctypes.c_double),
("gyrx", ctypes.c_double), ("gyry", ctypes.c_double), ("gyrz", ctypes.c_double),
("Roll", ctypes.c_double), ("Pitch", ctypes.c_double), ("Yaw", ctypes.c_double)]
def CreateRazorAHRSData():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.POINTER(RAZORAHRSDATA))
hApiParams = None
function_call = hApiProto(('CreateRazorAHRSDatax', hDll), hApiParams)
return function_call()
def DestroyRazorAHRSData(pRazorAHRSData):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.POINTER(RAZORAHRSDATA))
hApiParams = (1, "pRazorAHRSData", 0),
function_call = hApiProto(('DestroyRazorAHRSDatax', hDll), hApiParams)
function_call(pRazorAHRSData)
def CreateRazorAHRS():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateRazorAHRSx', hDll), hApiParams)
return function_call()
def DestroyRazorAHRS(pRazorAHRS):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pRazorAHRS", 0),
function_call = hApiProto(('DestroyRazorAHRSx', hDll), hApiParams)
function_call(pRazorAHRS)
def GetLatestDataRazorAHRS(pRazorAHRS):
global hDll
pRazorAHRSData = (RAZORAHRSDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(RAZORAHRSDATA))
hApiParams = (1, "pRazorAHRS", 0),(1, "pRazorAHRSData", 0),
function_call = hApiProto(('GetLatestDataRazorAHRSx', hDll), hApiParams)
res = function_call(pRazorAHRS, pRazorAHRSData)
return res, pRazorAHRSData[0]
def ConnectRazorAHRS(pRazorAHRS, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pRazorAHRS", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectRazorAHRSx', hDll), hApiParams)
return function_call(pRazorAHRS, cfgFilePath.encode('UTF-8'))
def DisconnectRazorAHRS(pRazorAHRS):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pRazorAHRS", 0),
function_call = hApiProto(('DisconnectRazorAHRSx', hDll), hApiParams)
return function_call(pRazorAHRS)
def GetLatestDataFromThreadRazorAHRS(pRazorAHRS):
global hDll
pRazorAHRSData = (RAZORAHRSDATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(RAZORAHRSDATA))
hApiParams = (1, "pRazorAHRS", 0),(1, "pRazorAHRSData", 0),
function_call = hApiProto(('GetLatestDataFromThreadRazorAHRSx', hDll), hApiParams)
res = function_call(pRazorAHRS, pRazorAHRSData)
return res, pRazorAHRSData[0]
def StartThreadRazorAHRS(pRazorAHRS):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pRazorAHRS", 0),
function_call = hApiProto(('StartThreadRazorAHRSx', hDll), hApiParams)
return function_call(pRazorAHRS)
def StopThreadRazorAHRS(pRazorAHRS):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pRazorAHRS", 0),
function_call = hApiProto(('StopThreadRazorAHRSx', hDll), hApiParams)
return function_call(pRazorAHRS)
def CreateMDM():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateMDMx', hDll), hApiParams)
return function_call()
def DestroyMDM(pMDM):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pMDM", 0),
function_call = hApiProto(('DestroyMDMx', hDll), hApiParams)
function_call(pMDM)
def SendDataMDM(pMDM, buf, buflen):
global hDll
pbuf = (ctypes.c_ubyte*(buflen))() # Memory leak here, rely on garbage collector?
for k in range(buflen):
pbuf[k] = ctypes.c_ubyte(int(buf[k]))
pSentBytes = (ctypes.c_int*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_ubyte), ctypes.c_int, ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pMDM", 0),(1, "pbuf", 0),(1, "buflen", 0),(1, "pSentBytes", 0),
function_call = hApiProto(('SendDataMDMx', hDll), hApiParams)
res = function_call(pMDM, pbuf, buflen, pSentBytes)
return res, pSentBytes[0]
def RecvDataMDM(pMDM, buf, buflen):
global hDll
pbuf = (ctypes.c_ubyte*(buflen))() # Memory leak here, rely on garbage collector?
for k in range(buflen):
pbuf[k] = ctypes.c_ubyte(int(buf[k]))
pReceivedBytes = (ctypes.c_int*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_ubyte), ctypes.c_int, ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pMDM", 0),(1, "pbuf", 0),(1, "buflen", 0),(1, "pReceivedBytes", 0),
function_call = hApiProto(('RecvDataMDMx', hDll), hApiParams)
res = function_call(pMDM, pbuf, buflen, pReceivedBytes)
for k in range(buflen):
buf[k] = pbuf[k]
return res, buf, pReceivedBytes[0]
def PurgeDataMDM(pMDM):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pMDM", 0),
function_call = hApiProto(('PurgeDataMDMx', hDll), hApiParams)
res = function_call(pMDM)
return res
def ConnectMDM(pMDM, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pMDM", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectMDMx', hDll), hApiParams)
return function_call(pMDM, cfgFilePath.encode('UTF-8'))
def DisconnectMDM(pMDM):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pMDM", 0),
function_call = hApiProto(('DisconnectMDMx', hDll), hApiParams)
return function_call(pMDM)
def CreateP33x():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateP33xx', hDll), hApiParams)
return function_call()
def DestroyP33x(pP33x):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pP33x", 0),
function_call = hApiProto(('DestroyP33xx', hDll), hApiParams)
function_call(pP33x)
def GetPressureP33x(pP33x):
global hDll
pPressure = (ctypes.c_double*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double))
hApiParams = (1, "pP33x", 0),(1, "pPressure", 0),
function_call = hApiProto(('GetPressureP33xx', hDll), hApiParams)
res = function_call(pP33x, pPressure)
return res, pPressure[0]
def GetTemperatureP33x(pP33x):
global hDll
pTemperature = (ctypes.c_double*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double))
hApiParams = (1, "pP33x", 0),(1, "pTemperature", 0),
function_call = hApiProto(('GetTemperatureP33xx', hDll), hApiParams)
res = function_call(pP33x, pTemperature)
return res, pTemperature[0]
def ConnectP33x(pP33x, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pP33x", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectP33xx', hDll), hApiParams)
return function_call(pP33x, cfgFilePath.encode('UTF-8'))
def DisconnectP33x(pP33x):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pP33x", 0),
function_call = hApiProto(('DisconnectP33xx', hDll), hApiParams)
return function_call(pP33x)
def GetPressureFromThreadP33x(pP33x):
global hDll
pPressure = (ctypes.c_double*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double))
hApiParams = (1, "pP33x", 0),(1, "pPressure", 0),
function_call = hApiProto(('GetPressureFromThreadP33xx', hDll), hApiParams)
res = function_call(pP33x, pPressure)
return res, pPressure[0]
def GetTemperatureFromThreadP33x(pP33x):
global hDll
pTemperature = (ctypes.c_double*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double))
hApiParams = (1, "pP33x", 0),(1, "pTemperature", 0),
function_call = hApiProto(('GetTemperatureFromThreadP33xx', hDll), hApiParams)
res = function_call(pP33x, pTemperature)
return res, pTemperature[0]
def StartThreadP33x(pP33x):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pP33x", 0),
function_call = hApiProto(('StartThreadP33xx', hDll), hApiParams)
return function_call(pP33x)
def StopThreadP33x(pP33x):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pP33x", 0),
function_call = hApiProto(('StopThreadP33xx', hDll), hApiParams)
return function_call(pP33x)
class NMEADATA(ctypes.Structure):
_fields_ = [("utc", ctypes.c_double), ("date", ctypes.c_double),
("pressure", ctypes.c_double), ("temperature", ctypes.c_double),
("cpressure", ctypes.c_char), ("ctemperature", ctypes.c_char),
("winddir", ctypes.c_double), ("windspeed", ctypes.c_double),
("cwinddir", ctypes.c_char), ("cwindspeed", ctypes.c_char),
("awinddir", ctypes.c_double), ("awindspeed", ctypes.c_double),
("cawinddir", ctypes.c_char), ("cawindspeed", ctypes.c_char),
("latdeg", ctypes.c_int), ("longdeg", ctypes.c_int),
("latmin", ctypes.c_double), ("longmin", ctypes.c_double),
("szlatdeg", ctypes.c_char*3), ("szlongdeg", ctypes.c_char*4),
("north", ctypes.c_char), ("east", ctypes.c_char),
("GPS_quality_indicator", ctypes.c_int),
("nbsat", ctypes.c_int),
("hdop", ctypes.c_double),
("height_geoid", ctypes.c_double),
("status", ctypes.c_char),
("posMode", ctypes.c_char),
("sog", ctypes.c_double), ("kph", ctypes.c_double), ("cog", ctypes.c_double), ("mag_cog", ctypes.c_double),
("heading", ctypes.c_double), ("deviation", ctypes.c_double), ("variation", ctypes.c_double),
("dev_east", ctypes.c_char), ("var_east", ctypes.c_char),
("rateofturn", ctypes.c_double),
("wplatdeg", ctypes.c_int), ("wplongdeg", ctypes.c_int),
("wplatmin", ctypes.c_double), ("wplongmin", ctypes.c_double),
("szwplatdeg", ctypes.c_char*3), ("szwplongdeg", ctypes.c_char*4),
("wpnorth", ctypes.c_char), ("wpeast", ctypes.c_char),
("szwpname", ctypes.c_char*64),
("totalrtemsg", ctypes.c_int), ("rtemsgnb", ctypes.c_int),
("rtemsgmode", ctypes.c_char),
("szrtewp1name", ctypes.c_char*64),
("szrtewp2name", ctypes.c_char*64),
("szrtewp3name", ctypes.c_char*64),
("szrtewp4name", ctypes.c_char*64),
("nbsentences", ctypes.c_int),
("sentence_number", ctypes.c_int),
("seqmsgid", ctypes.c_int),
("AIS_channel", ctypes.c_char),
("nbfillbits", ctypes.c_int),
("roll", ctypes.c_double), ("pitch", ctypes.c_double),
("salinity", ctypes.c_double),
("depth", ctypes.c_double),
("speedofsound", ctypes.c_double),
("vx_dvl", ctypes.c_double), ("vy_dvl", ctypes.c_double), ("vz_dvl", ctypes.c_double), ("verr_dvl", ctypes.c_double), ("vt_ship", ctypes.c_double), ("vl_ship", ctypes.c_double), ("vn_ship", ctypes.c_double), ("v_east", ctypes.c_double), ("v_north", ctypes.c_double), ("v_up", ctypes.c_double),
("vstatus_dvl", ctypes.c_char), ("vstatus_ship", ctypes.c_char), ("vstatus_earth", ctypes.c_char),
("d_east", ctypes.c_double), ("d_north", ctypes.c_double), ("d_up", ctypes.c_double), ("rangetobottom", ctypes.c_double),
("timesincelastgood", ctypes.c_double),
("Latitude", ctypes.c_double),
("Longitude", ctypes.c_double),
("Altitude", ctypes.c_double),
("Altitude_AGL", ctypes.c_double),
("SOG", ctypes.c_double),
("COG", ctypes.c_double),
("year", ctypes.c_int), ("month", ctypes.c_int), ("day", ctypes.c_int), ("hour", ctypes.c_int), ("minute", ctypes.c_int),
("second", ctypes.c_double),
("Roll", ctypes.c_double),
("Pitch", ctypes.c_double),
("Heading", ctypes.c_double),
("RateOfTurn", ctypes.c_double),
("WindDir", ctypes.c_double),
("WindSpeed", ctypes.c_double),
("ApparentWindDir", ctypes.c_double),
("ApparentWindSpeed", ctypes.c_double),
("wpLatitude", ctypes.c_double),
("wpLongitude", ctypes.c_double),
("AIS_Latitude", ctypes.c_double),
("AIS_Longitude", ctypes.c_double),
("AIS_SOG", ctypes.c_double),
("AIS_COG", ctypes.c_double)]
def CreateNMEAData():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.POINTER(NMEADATA))
hApiParams = None
function_call = hApiProto(('CreateNMEADatax', hDll), hApiParams)
return function_call()
def DestroyNMEAData(pNMEAData):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.POINTER(NMEADATA))
hApiParams = (1, "pNMEAData", 0),
function_call = hApiProto(('DestroyNMEADatax', hDll), hApiParams)
function_call(pNMEAData)
def CreateNMEADevice():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateNMEADevicex', hDll), hApiParams)
return function_call()
def DestroyNMEADevice(pNMEADevice):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pNMEADevice", 0),
function_call = hApiProto(('DestroyNMEADevicex', hDll), hApiParams)
function_call(pNMEADevice)
def GetLatestDataNMEADevice(pNMEADevice):
global hDll
pNMEAData = (NMEADATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(NMEADATA))
hApiParams = (1, "pNMEADevice", 0),(1, "pNMEAData", 0),
function_call = hApiProto(('GetLatestDataNMEADevicex', hDll), hApiParams)
res = function_call(pNMEADevice, pNMEAData)
return res, pNMEAData[0]
def ConnectNMEADevice(pNMEADevice, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pNMEADevice", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectNMEADevicex', hDll), hApiParams)
return function_call(pNMEADevice, cfgFilePath.encode('UTF-8'))
def DisconnectNMEADevice(pNMEADevice):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pNMEADevice", 0),
function_call = hApiProto(('DisconnectNMEADevicex', hDll), hApiParams)
return function_call(pNMEADevice)
def GetLatestDataFromThreadNMEADevice(pNMEADevice):
global hDll
pNMEAData = (NMEADATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(NMEADATA))
hApiParams = (1, "pNMEADevice", 0),(1, "pNMEAData", 0),
function_call = hApiProto(('GetLatestDataFromThreadNMEADevicex', hDll), hApiParams)
res = function_call(pNMEADevice, pNMEAData)
return res, pNMEAData[0]
def StartThreadNMEADevice(pNMEADevice):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pNMEADevice", 0),
function_call = hApiProto(('StartThreadNMEADevicex', hDll), hApiParams)
return function_call(pNMEADevice)
def StopThreadNMEADevice(pNMEADevice):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pNMEADevice", 0),
function_call = hApiProto(('StopThreadNMEADevicex', hDll), hApiParams)
return function_call(pNMEADevice)
#class UBXDATA(ctypes.Structure):
# _pack_ = 1
# _fields_ = ...
def Createublox():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('Createubloxx', hDll), hApiParams)
return function_call()
def Destroyublox(publox):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "publox", 0),
function_call = hApiProto(('Destroyubloxx', hDll), hApiParams)
function_call(publox)
def GetNMEASentenceublox(publox):
global hDll
pNMEAData = (NMEADATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(NMEADATA))
hApiParams = (1, "publox", 0),(1, "pNMEAData", 0),
function_call = hApiProto(('GetNMEASentenceubloxx', hDll), hApiParams)
res = function_call(publox, pNMEAData)
return res, pNMEAData[0]
def Connectublox(publox, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "publox", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('Connectubloxx', hDll), hApiParams)
return function_call(publox, cfgFilePath.encode('UTF-8'))
def Disconnectublox(publox):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "publox", 0),
function_call = hApiProto(('Disconnectubloxx', hDll), hApiParams)
return function_call(publox)
def GetNMEASentenceFromThreadublox(publox):
global hDll
pNMEAData = (NMEADATA*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(NMEADATA))
hApiParams = (1, "publox", 0),(1, "pNMEAData", 0),
function_call = hApiProto(('GetNMEASentenceFromThreadubloxx', hDll), hApiParams)
res = function_call(publox, pNMEAData)
return res, pNMEAData[0]
def StartNMEAThreadublox(publox):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "publox", 0),
function_call = hApiProto(('StartNMEAThreadubloxx', hDll), hApiParams)
return function_call(publox)
def StopNMEAThreadublox(publox):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "publox", 0),
function_call = hApiProto(('StopNMEAThreadubloxx', hDll), hApiParams)
return function_call(publox)
def CreateIM483I():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateIM483Ix', hDll), hApiParams)
return function_call()
def DestroyIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('DestroyIM483Ix', hDll), hApiParams)
function_call(pIM483I)
def SetMotorTorqueIM483I(pIM483I, holdpercent, runpercent):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
hApiParams = (1, "pIM483I", 0),(1, "holdpercent", 0),(1, "runpercent", 0),
function_call = hApiProto(('SetMotorTorqueIM483Ix', hDll), hApiParams)
return function_call(pIM483I, holdpercent, runpercent)
def SetMotorSpeedIM483I(pIM483I, val):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int)
hApiParams = (1, "pIM483I", 0),(1, "val", 0),
function_call = hApiProto(('SetMotorSpeedIM483Ix', hDll), hApiParams)
return function_call(pIM483I, val)
def SetMotorRelativeIM483I(pIM483I, val, bForce):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
hApiParams = (1, "pIM483I", 0),(1, "val", 0),(1, "bForce", 0),
function_call = hApiProto(('SetMotorSpeedIM483Ix', hDll), hApiParams)
return function_call(pIM483I, val, bForce)
def SetMotorOriginIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('SetMotorOriginIM483Ix', hDll), hApiParams)
return function_call(pIM483I)
def SetMaxAngleIM483I(pIM483I, angle):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_double)
hApiParams = (1, "pIM483I", 0),(1, "angle", 0),
function_call = hApiProto(('SetMaxAngleIM483Ix', hDll), hApiParams)
return function_call(pIM483I, angle)
def CalibrateIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('CalibrateIM483Ix', hDll), hApiParams)
return function_call(pIM483I)
def ConnectIM483I(pIM483I, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pIM483I", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectIM483Ix', hDll), hApiParams)
return function_call(pIM483I, cfgFilePath.encode('UTF-8'))
def DisconnectIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('DisconnectIM483Ix', hDll), hApiParams)
return function_call(pIM483I)
def SetMaxAngleFromThreadIM483I(pIM483I, angle):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_double)
hApiParams = (1, "pIM483I", 0),(1, "angle", 0),
function_call = hApiProto(('SetMaxAngleFromThreadIM483Ix', hDll), hApiParams)
return function_call(pIM483I, angle)
def StartThreadIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('StartThreadIM483Ix', hDll), hApiParams)
return function_call(pIM483I)
def StopThreadIM483I(pIM483I):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pIM483I", 0),
function_call = hApiProto(('StopThreadIM483Ix', hDll), hApiParams)
return function_call(pIM483I)
def CreateSSC32():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreateSSC32x', hDll), hApiParams)
return function_call()
def DestroySSC32(pSSC32):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pSSC32", 0),
function_call = hApiProto(('DestroySSC32x', hDll), hApiParams)
function_call(pSSC32)
def GetVoltageSSC32(pSSC32, channel):
global hDll
pvoltage = (ctypes.c_double*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_double))
hApiParams = (1, "pSSC32", 0),(1, "channel", 0),(1, "pvoltage", 0),
function_call = hApiProto(('GetVoltageSSC32x', hDll), hApiParams)
res = function_call(pSSC32, channel, pvoltage)
return res, pvoltage[0]
def GetDigitalInputSSC32(pSSC32, channel):
global hDll
pValue = (ctypes.c_int*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pSSC32", 0),(1, "channel", 0),(1, "pValue", 0),
function_call = hApiProto(('GetDigitalInputSSC32x', hDll), hApiParams)
res = function_call(pSSC32, channel, pValue)
return res, pValue[0]
def GetPWMSSC32(pSSC32, channel):
global hDll
ppw = (ctypes.c_int*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pSSC32", 0),(1, "channel", 0),(1, "ppw", 0),
function_call = hApiProto(('GetPWMSSC32x', hDll), hApiParams)
res = function_call(pSSC32, channel, ppw)
return res, ppw[0]
def SetPWMSSC32(pSSC32, channel, pw):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
hApiParams = (1, "pSSC32", 0),(1, "channel", 0),(1, "pw", 0),
function_call = hApiProto(('SetPWMSSC32x', hDll), hApiParams)
return function_call(pSSC32, channel, pw)
def SetAllPWMsSSC32(pSSC32, selectedchannels, pws):
global hDll
nbchannels = 32
pselectedchannels = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
pselectedchannels[k] = ctypes.c_int(int(selectedchannels[k]))
ppws = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
ppws[k] = ctypes.c_int(pws[k])
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pSSC32", 0),(1, "pselectedchannels", 0),(1, "ppws", 0),
function_call = hApiProto(('SetAllPWMsSSC32x', hDll), hApiParams)
return function_call(pSSC32, pselectedchannels, ppws)
def SetDigitalOutputSSC32(pSSC32, channel, value):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
hApiParams = (1, "pSSC32", 0),(1, "channel", 0),(1, "value", 0),
function_call = hApiProto(('SetDigitalOutputSSC32x', hDll), hApiParams)
return function_call(pSSC32, channel, value)
def ConnectSSC32(pSSC32, cfgFilePath):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p)
hApiParams = (1, "pSSC32", 0),(1, "cfgFilePath", 0),
function_call = hApiProto(('ConnectSSC32x', hDll), hApiParams)
return function_call(pSSC32, cfgFilePath.encode('UTF-8'))
def DisconnectSSC32(pSSC32):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSSC32", 0),
function_call = hApiProto(('DisconnectSSC32x', hDll), hApiParams)
return function_call(pSSC32)
def SetAllPWMsFromThreadSSC32(pSSC32, selectedchannels, pws):
global hDll
nbchannels = 32
pselectedchannels = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
pselectedchannels[k] = ctypes.c_int(int(selectedchannels[k]))
ppws = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
ppws[k] = ctypes.c_int(pws[k])
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pSSC32", 0),(1, "pselectedchannels", 0),(1, "ppws", 0),
function_call = hApiProto(('SetAllPWMsFromThreadSSC32x', hDll), hApiParams)
return function_call(pSSC32, pselectedchannels, ppws)
def StartThreadSSC32(pSSC32):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSSC32", 0),
function_call = hApiProto(('StartThreadSSC32x', hDll), hApiParams)
return function_call(pSSC32)
def StopThreadSSC32(pSSC32):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
hApiParams = (1, "pSSC32", 0),
function_call = hApiProto(('StopThreadSSC32x', hDll), hApiParams)
return function_call(pSSC32)
def CreatePololu():
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_void_p)
hApiParams = None
function_call = hApiProto(('CreatePololux', hDll), hApiParams)
return function_call()
def DestroyPololu(pPololu):
global hDll
hApiProto = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
hApiParams = (1, "pPololu", 0),
function_call = hApiProto(('DestroyPololux', hDll), hApiParams)
function_call(pPololu)
def GetValuePololu(pPololu, channel):
global hDll
pValue = (ctypes.c_int*(1))() # Memory leak here, rely on garbage collector?
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pPololu", 0),(1, "channel", 0),(1, "pValue", 0),
function_call = hApiProto(('GetValuePololux', hDll), hApiParams)
res = function_call(pPololu, channel, pValue)
return res, pValue[0]
def GetAllValuesPololu(pPololu, selectedchannels, ais):
global hDll
nbchannels = 24
pselectedchannels = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
pselectedchannels[k] = ctypes.c_int(int(selectedchannels[k]))
pais = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
pais[k] = ctypes.c_int(ais[k])
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
hApiParams = (1, "pPololu", 0),(1, "pselectedchannels", 0),(1, "pais", 0),
function_call = hApiProto(('GetAllValuesPololux', hDll), hApiParams)
return function_call(pPololu, pselectedchannels, pais)
def SetPWMPololu(pPololu, channel, pw):
global hDll
hApiProto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
hApiParams = (1, "pPololu", 0),(1, "channel", 0),(1, "pw", 0),
function_call = hApiProto(('SetPWMPololux', hDll), hApiParams)
return function_call(pPololu, channel, pw)
def SetAllPWMsPololu(pPololu, selectedchannels, pws):
global hDll
nbchannels = 24
pselectedchannels = (ctypes.c_int*(nbchannels))() # Memory leak here, rely on garbage collector?
for k in range(nbchannels):
pselectedchannels[k] = ctypes.c_int(int(selectedchannels[k]))