@litmusio/miravo-cli-darwin-arm64 0.0.0-stage → 0.15.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +199 -0
- package/NOTICE +9 -0
- package/README.md +6 -2
- package/THIRD_PARTY_LICENSES.txt +15289 -0
- package/THIRD_PARTY_NOTICES.md +995 -0
- package/console-dist/assets/AnimatePresence-DWGUB15i.js +9 -0
- package/console-dist/assets/activity-DruTYzT1.js +1 -0
- package/console-dist/assets/api-13R-Szmo.js +57 -0
- package/console-dist/assets/arrow-up-right-DOENs04V.js +1 -0
- package/console-dist/assets/asset-detail-D142l0Fv.js +1 -0
- package/console-dist/assets/asset-detail-actions-Cf9kIXus.js +1 -0
- package/console-dist/assets/backup-power-B2I59W_p.js +1 -0
- package/console-dist/assets/badge-CdRB4Nd_.js +1 -0
- package/console-dist/assets/boiler-s_q0j7rz.js +1 -0
- package/console-dist/assets/by-path-BVKB6Tic.js +1 -0
- package/console-dist/assets/check-BTUv4z-H.js +1 -0
- package/console-dist/assets/chevron-down-CqA_2_CH.js +1 -0
- package/console-dist/assets/chevron-right-CVrgKBLR.js +1 -0
- package/console-dist/assets/chiller-r7DzAhJq.js +1 -0
- package/console-dist/assets/chunk-6KYCQHYJ-ga3Yekab.js +3 -0
- package/console-dist/assets/circle-x-BRkh0A1P.js +1 -0
- package/console-dist/assets/commercial-building-YWHjdNWm.js +1 -0
- package/console-dist/assets/compressor-ChZLMC94.js +1 -0
- package/console-dist/assets/console-panel-CnTkf-Zr.js +1 -0
- package/console-dist/assets/dialog-BYkdndf9.js +1 -0
- package/console-dist/assets/district-heating-DaU-3LzU.js +1 -0
- package/console-dist/assets/dom-BxZbg3NX.js +1 -0
- package/console-dist/assets/download-CvjDP5mu.js +1 -0
- package/console-dist/assets/fira-code-cyrillic-ext-wght-normal-DhYMMuQd.woff2 +0 -0
- package/console-dist/assets/fira-code-cyrillic-wght-normal-Y3u8pIsh.woff2 +0 -0
- package/console-dist/assets/fira-code-greek-ext-wght-normal-wWus70Ix.woff2 +0 -0
- package/console-dist/assets/fira-code-greek-wght-normal-B2SviObF.woff2 +0 -0
- package/console-dist/assets/fira-code-latin-ext-wght-normal-Dvfvaomy.woff2 +0 -0
- package/console-dist/assets/fira-code-latin-wght-normal-CHoedHDv.woff2 +0 -0
- package/console-dist/assets/fira-code-symbols2-wght-normal-CE6EOz_n.woff2 +0 -0
- package/console-dist/assets/floor-page-CiAcIxAW.js +1 -0
- package/console-dist/assets/floor-page-E-0txA4z.css +1 -0
- package/console-dist/assets/format-YLUJ7AXt.js +1 -0
- package/console-dist/assets/genset-C6_EUoFo.js +1 -0
- package/console-dist/assets/index-Cf8qRbyA.js +15 -0
- package/console-dist/assets/index-eZjXAdLh.css +2 -0
- package/console-dist/assets/loader-circle-w3T2fxvn.js +1 -0
- package/console-dist/assets/login-DP7gR4IQ.js +136 -0
- package/console-dist/assets/not-found-DeZnLH0i.js +1 -0
- package/console-dist/assets/pharma-cleanroom-DvWD_xsO.js +1 -0
- package/console-dist/assets/preload-helper-7y9sWmk5.js +1 -0
- package/console-dist/assets/react-DRt7cCXI.js +1 -0
- package/console-dist/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
- package/console-dist/assets/rtu-ByogcRPI.js +1 -0
- package/console-dist/assets/runtime-link-D88Db2wY.js +1 -0
- package/console-dist/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
- package/console-dist/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
- package/console-dist/assets/server-B0q1NVkV.js +1 -0
- package/console-dist/assets/shallow-mIK1Qu8X.js +1 -0
- package/console-dist/assets/smart-factory-gfMWfMWM.js +1 -0
- package/console-dist/assets/source-host-miravo-BW-SKMTe.js +1 -0
- package/console-dist/assets/stages-EYRT12Yp.js +1 -0
- package/console-dist/assets/status-DQYLUbXs.js +1 -0
- package/console-dist/assets/tank-Btg5piqB.js +1 -0
- package/console-dist/assets/tooltip-Dfmuq2yz.js +1 -0
- package/console-dist/assets/trash-2-BAh5-hxl.js +1 -0
- package/console-dist/assets/triangle-alert-3Ab-dBrN.js +1 -0
- package/console-dist/assets/use-engine-command-mutation-BXSIzBAw.js +1 -0
- package/console-dist/assets/use-transition-navigate-COPPNZaw.js +2 -0
- package/console-dist/assets/useQuery-BbehJ-ez.js +1 -0
- package/console-dist/assets/utils-D6wrZy-b.js +1 -0
- package/console-dist/assets/validation-6JNiaZvb.js +1 -0
- package/console-dist/assets/vendor-charts-Bquh2dWE.js +56 -0
- package/console-dist/assets/vendor-table-5YnGQUhO.js +4 -0
- package/console-dist/assets/vendor-ui-BGeFlRLR.js +1 -0
- package/console-dist/assets/water-treatment-BkzNjsHx.js +1 -0
- package/console-dist/icon.png +0 -0
- package/console-dist/index.html +53 -0
- package/console-dist/miravo-logo.webp +0 -0
- package/licenses/EPL-2.0.txt +80 -0
- package/licenses/GCC-exception-3.1.txt +33 -0
- package/licenses/GPL-2.0-only.txt +117 -0
- package/licenses/GPL-3.0-only.txt +232 -0
- package/licenses/LGPL-2.1-only.txt +176 -0
- package/licenses/MPL-2.0.txt +373 -0
- package/licenses/OFL-1.1.txt +93 -0
- package/licenses/overrides/@headlessui+vue@1.7.23.txt +24 -0
- package/licenses/overrides/@next+env@16.4.6.txt +24 -0
- package/licenses/overrides/@radix-ui+react-compose-refs@1.1.2.txt +24 -0
- package/licenses/overrides/@radix-ui+react-context@1.1.2.txt +24 -0
- package/licenses/overrides/@radix-ui+react-direction@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-id@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-callback-ref@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-escape-keydown@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-layout-effect@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-rect@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-size@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+rect@1.1.1.txt +24 -0
- package/licenses/overrides/@replit+codemirror-css-color-picker@6.3.0.txt +6 -0
- package/licenses/overrides/@scalar+openapi-types@0.8.0.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.10.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.7.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.9.txt +24 -0
- package/licenses/overrides/@scalar+postman-to-openapi@0.7.1.txt +24 -0
- package/licenses/overrides/@scalar+schemas@0.19.0.txt +24 -0
- package/licenses/overrides/@scalar+workspace-store@0.46.3.txt +24 -0
- package/licenses/overrides/@scalar+workspace-store@0.75.0.txt +24 -0
- package/licenses/overrides/assert-plus@1.0.0.txt +24 -0
- package/licenses/overrides/client-only@0.0.1.txt +24 -0
- package/licenses/overrides/embla-carousel-react@8.6.0.txt +24 -0
- package/licenses/overrides/embla-carousel-reactive-utils@8.6.0.txt +24 -0
- package/licenses/overrides/embla-carousel@8.6.0.txt +24 -0
- package/licenses/overrides/fastdom@1.0.12.txt +12 -0
- package/licenses/overrides/precond@0.2.3.txt +22 -0
- package/licenses/overrides/react-remove-scroll-bar@2.3.8.txt +24 -0
- package/licenses/overrides/strictdom@1.0.1.txt +12 -0
- package/licenses/overrides/victory-vendor@36.9.2.txt +33 -0
- package/licenses/runtime/Bun-1.4.3-LICENSE.md +85 -0
- package/licenses/runtime/ICU-78.1-LICENSE.txt +568 -0
- package/licenses/runtime/bun-components/boringssl.txt +238 -0
- package/licenses/runtime/bun-components/brotli.txt +19 -0
- package/licenses/runtime/bun-components/c-ares.txt +24 -0
- package/licenses/runtime/bun-components/highway.txt +371 -0
- package/licenses/runtime/bun-components/libarchive.txt +65 -0
- package/licenses/runtime/bun-components/libbase64.txt +28 -0
- package/licenses/runtime/bun-components/libdeflate.txt +22 -0
- package/licenses/runtime/bun-components/libjpeg-turbo.txt +147 -0
- package/licenses/runtime/bun-components/libspng.txt +25 -0
- package/licenses/runtime/bun-components/libuv.txt +19 -0
- package/licenses/runtime/bun-components/libwebp.txt +30 -0
- package/licenses/runtime/bun-components/llvm.txt +311 -0
- package/licenses/runtime/bun-components/lol-html.txt +27 -0
- package/licenses/runtime/bun-components/ls-hpack.txt +21 -0
- package/licenses/runtime/bun-components/ls-qpack.txt +21 -0
- package/licenses/runtime/bun-components/lsquic-chrome.txt +32 -0
- package/licenses/runtime/bun-components/lsquic.txt +21 -0
- package/licenses/runtime/bun-components/mimalloc.txt +21 -0
- package/licenses/runtime/bun-components/picohttpparser.txt +24 -0
- package/licenses/runtime/bun-components/simdutf-apache.txt +201 -0
- package/licenses/runtime/bun-components/simdutf-mit.txt +18 -0
- package/licenses/runtime/bun-components/tigerbeetle.txt +177 -0
- package/licenses/runtime/bun-components/tinycc.txt +504 -0
- package/licenses/runtime/bun-components/typescript-go.txt +55 -0
- package/licenses/runtime/bun-components/usockets.txt +201 -0
- package/licenses/runtime/bun-components/uucode.txt +30 -0
- package/licenses/runtime/bun-components/uwebsockets.txt +201 -0
- package/licenses/runtime/bun-components/xxhash.txt +31 -0
- package/licenses/runtime/bun-components/zlib-ng.txt +19 -0
- package/licenses/runtime/bun-components/zstd-copying.txt +339 -0
- package/licenses/runtime/bun-components/zstd.txt +30 -0
- package/licenses/runtime/musl-1.2.6-COPYRIGHT.txt +193 -0
- package/miravo +4 -0
- package/native/S7-NOTICES.txt +11 -0
- package/native/miravo-s7.node +0 -0
- package/native/s7-source/CMakeLists.txt +23 -0
- package/native/s7-source/NODE-SNAP7-LICENSE +24 -0
- package/native/s7-source/addon.cpp +124 -0
- package/native/s7-source/bridge.cpp +150 -0
- package/native/s7-source/node-api-headers/LICENSE +21 -0
- package/native/s7-source/node-api-headers/include/js_native_api.h +591 -0
- package/native/s7-source/node-api-headers/include/js_native_api_types.h +213 -0
- package/native/s7-source/node-api-headers/include/node_api.h +265 -0
- package/native/s7-source/node-api-headers/include/node_api_types.h +58 -0
- package/native/s7-source/node-api-windows.h +78 -0
- package/native/s7-source/snap7/HISTORY.txt +277 -0
- package/native/s7-source/snap7/gpl.txt +674 -0
- package/native/s7-source/snap7/lgpl-3.0.txt +165 -0
- package/native/s7-source/snap7/src/core/miravo_request_validation.h +72 -0
- package/native/s7-source/snap7/src/core/s7_client.cpp +503 -0
- package/native/s7-source/snap7/src/core/s7_client.h +104 -0
- package/native/s7-source/snap7/src/core/s7_firmware.h +1256 -0
- package/native/s7-source/snap7/src/core/s7_isotcp.cpp +541 -0
- package/native/s7-source/snap7/src/core/s7_isotcp.h +271 -0
- package/native/s7-source/snap7/src/core/s7_micro_client.cpp +3328 -0
- package/native/s7-source/snap7/src/core/s7_micro_client.h +364 -0
- package/native/s7-source/snap7/src/core/s7_partner.cpp +1178 -0
- package/native/s7-source/snap7/src/core/s7_partner.h +284 -0
- package/native/s7-source/snap7/src/core/s7_peer.cpp +121 -0
- package/native/s7-source/snap7/src/core/s7_peer.h +58 -0
- package/native/s7-source/snap7/src/core/s7_server.cpp +2161 -0
- package/native/s7-source/snap7/src/core/s7_server.h +261 -0
- package/native/s7-source/snap7/src/core/s7_text.cpp +788 -0
- package/native/s7-source/snap7/src/core/s7_text.h +49 -0
- package/native/s7-source/snap7/src/core/s7_types.h +1066 -0
- package/native/s7-source/snap7/src/lib/snap7.def +129 -0
- package/native/s7-source/snap7/src/lib/snap7_libmain.cpp +1196 -0
- package/native/s7-source/snap7/src/lib/snap7_libmain.h +201 -0
- package/native/s7-source/snap7/src/sys/snap_msgsock.cpp +958 -0
- package/native/s7-source/snap7/src/sys/snap_msgsock.h +339 -0
- package/native/s7-source/snap7/src/sys/snap_platform.h +152 -0
- package/native/s7-source/snap7/src/sys/snap_sysutils.cpp +73 -0
- package/native/s7-source/snap7/src/sys/snap_sysutils.h +39 -0
- package/native/s7-source/snap7/src/sys/snap_tcpsrvr.cpp +487 -0
- package/native/s7-source/snap7/src/sys/snap_tcpsrvr.h +247 -0
- package/native/s7-source/snap7/src/sys/snap_threads.cpp +162 -0
- package/native/s7-source/snap7/src/sys/snap_threads.h +45 -0
- package/native/s7-source/snap7/src/sys/sol_threads.h +208 -0
- package/native/s7-source/snap7/src/sys/unix_threads.h +228 -0
- package/native/s7-source/snap7/src/sys/win_threads.h +159 -0
- package/nodesets/.ignore +1 -0
- package/nodesets/1.02/FTNIR.NodeSet2.xml +819 -0
- package/nodesets/1.02/Opc.Ua.Adi.NodeSet2.xml +8301 -0
- package/nodesets/1.02/Opc.Ua.Di.NodeSet2.xml +1785 -0
- package/nodesets/Opc.ISA95.NodeSet2.xml +3589 -0
- package/nodesets/Opc.Ua.AMB.NodeSet2.xml +1395 -0
- package/nodesets/Opc.Ua.Adi.NodeSet2.xml +8301 -0
- package/nodesets/Opc.Ua.Adi.Types.xsd +104 -0
- package/nodesets/Opc.Ua.AutoID.NodeSet2.xml +6062 -0
- package/nodesets/Opc.Ua.CNC.NodeSet.xml +15875 -0
- package/nodesets/Opc.Ua.CommercialKitchenEquipment.NodeSet2.xml +12096 -0
- package/nodesets/Opc.Ua.Di.NodeSet2.xml +6042 -0
- package/nodesets/Opc.Ua.Di.Types.xsd +161 -0
- package/nodesets/Opc.Ua.Eumabois.Nodeset2.xml +2483 -0
- package/nodesets/Opc.Ua.Gds.NodeSet2.xml +8282 -0
- package/nodesets/Opc.Ua.Glass.NodeSet2.xml +5100 -0
- package/nodesets/Opc.Ua.IA.NodeSet2.xml +1782 -0
- package/nodesets/Opc.Ua.IOLink.NodeSet2.xml +4374 -0
- package/nodesets/Opc.Ua.IOLinkIODD.NodeSet2.xml +139 -0
- package/nodesets/Opc.Ua.IRDI.NodeSet2.xml +2243 -0
- package/nodesets/Opc.Ua.Ijt.Base.NodeSet2.xml +19459 -0
- package/nodesets/Opc.Ua.Ijt.Tightening.NodeSet2.xml +883 -0
- package/nodesets/Opc.Ua.LADS.NodeSet2.xml +7086 -0
- package/nodesets/Opc.Ua.MachineTool.NodeSet2.xml +7884 -0
- package/nodesets/Opc.Ua.MachineVision.NodeSet2.xml +17324 -0
- package/nodesets/Opc.Ua.Machinery.Jobs.Nodeset2.xml +1249 -0
- package/nodesets/Opc.Ua.Machinery.NodeSet2.xml +2099 -0
- package/nodesets/Opc.Ua.Machinery.ProcessValues.NodeSet2.xml +1858 -0
- package/nodesets/Opc.Ua.Machinery_Result.NodeSet2.xml +2640 -0
- package/nodesets/Opc.Ua.MetalForming.NodeSet2.xml +1577 -0
- package/nodesets/Opc.Ua.NodeSet2.xml +81975 -0
- package/nodesets/Opc.Ua.PADIM.NodeSet2.xml +14131 -0
- package/nodesets/Opc.Ua.PackML.NodeSet2.xml +3030 -0
- package/nodesets/Opc.Ua.Robotics.NodeSet2.xml +7409 -0
- package/nodesets/Opc.Ua.Scales.NodeSet2.xml +15817 -0
- package/nodesets/Opc.Ua.Types.bsd +3499 -0
- package/nodesets/Opc.Ua.Weihenstephan.NodeSet2.xml +821 -0
- package/nodesets/Opc.Ua.Woodworking.NodeSet2.xml +17831 -0
- package/nodesets/UANodeSet.xsd +497 -0
- package/nodesets/opc.ua.isa95-jobcontrol.nodeset2.xml +4594 -0
- package/package.json +34 -4
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#ifndef snap_msgsock_h
|
|
27
|
+
#define snap_msgsock_h
|
|
28
|
+
//---------------------------------------------------------------------------
|
|
29
|
+
#include "snap_platform.h"
|
|
30
|
+
#include "snap_sysutils.h"
|
|
31
|
+
//----------------------------------------------------------------------------
|
|
32
|
+
#if !defined(MSG_NOSIGNAL) && (defined(OS_WINDOWS) || defined(OS_SOLARIS) || defined(OS_OSX))
|
|
33
|
+
# define MSG_NOSIGNAL 0
|
|
34
|
+
#endif
|
|
35
|
+
//----------------------------------------------------------------------------
|
|
36
|
+
// Non blocking connection to avoid root priviledges under UNIX
|
|
37
|
+
// i.e. raw socket pinger is not more used.
|
|
38
|
+
// Thanks to Rolf Stalder that made it ;)
|
|
39
|
+
//----------------------------------------------------------------------------
|
|
40
|
+
#ifdef PLATFORM_UNIX
|
|
41
|
+
#define NON_BLOCKING_CONNECT
|
|
42
|
+
#endif
|
|
43
|
+
#ifdef NON_BLOCKING_CONNECT
|
|
44
|
+
#include <fcntl.h>
|
|
45
|
+
#endif
|
|
46
|
+
//----------------------------------------------------------------------------
|
|
47
|
+
/*
|
|
48
|
+
In Windows sizeof socket varies depending of the platform :
|
|
49
|
+
win32 -> sizeof(SOCKET) = 4
|
|
50
|
+
win64 -> sizeof(SOCKET) = 8
|
|
51
|
+
|
|
52
|
+
Even though sizeof(SOCKET) is 8, should be safe to cast it to int, because
|
|
53
|
+
the value constitutes an index in per-process table of limited size
|
|
54
|
+
and not a real pointer.
|
|
55
|
+
|
|
56
|
+
Other Os define the socket as int regardless of the processor.
|
|
57
|
+
|
|
58
|
+
We want to sleep peacefully, so it's better to define a portable socket.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
#ifdef OS_WINDOWS
|
|
62
|
+
typedef SOCKET socket_t;
|
|
63
|
+
#else
|
|
64
|
+
typedef int socket_t;
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
//----------------------------------------------------------------------------
|
|
68
|
+
#define SD_RECEIVE 0x00
|
|
69
|
+
#define SD_SEND 0x01
|
|
70
|
+
#define SD_BOTH 0x02
|
|
71
|
+
#define MaxPacketSize 65536
|
|
72
|
+
|
|
73
|
+
//----------------------------------------------------------------------------
|
|
74
|
+
// For other platform we need to re-define next constants
|
|
75
|
+
#if defined(PLATFORM_UNIX) || defined(OS_OSX)
|
|
76
|
+
|
|
77
|
+
#define INVALID_SOCKET (socket_t)(~0)
|
|
78
|
+
#define SOCKET_ERROR (-1)
|
|
79
|
+
|
|
80
|
+
#define WSAEINTR EINTR
|
|
81
|
+
#define WSAEBADF EBADF
|
|
82
|
+
#define WSAEACCES EACCES
|
|
83
|
+
#define WSAEFAULT EFAULT
|
|
84
|
+
#define WSAEINVAL EINVAL
|
|
85
|
+
#define WSAEMFILE EMFILE
|
|
86
|
+
#define WSAEWOULDBLOCK EWOULDBLOCK
|
|
87
|
+
#define WSAEINPROGRESS EINPROGRESS
|
|
88
|
+
#define WSAEALREADY EALREADY
|
|
89
|
+
#define WSAENOTSOCK ENOTSOCK
|
|
90
|
+
#define WSAEDESTADDRREQ EDESTADDRREQ
|
|
91
|
+
#define WSAEMSGSIZE EMSGSIZE
|
|
92
|
+
#define WSAEPROTOTYPE EPROTOTYPE
|
|
93
|
+
#define WSAENOPROTOOPT ENOPROTOOPT
|
|
94
|
+
#define WSAEPROTONOSUPPORT EPROTONOSUPPORT
|
|
95
|
+
#define WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT
|
|
96
|
+
#define WSAEOPNOTSUPP EOPNOTSUPP
|
|
97
|
+
#define WSAEPFNOSUPPORT EPFNOSUPPORT
|
|
98
|
+
#define WSAEAFNOSUPPORT EAFNOSUPPORT
|
|
99
|
+
#define WSAEADDRINUSE EADDRINUSE
|
|
100
|
+
#define WSAEADDRNOTAVAIL EADDRNOTAVAIL
|
|
101
|
+
#define WSAENETDOWN ENETDOWN
|
|
102
|
+
#define WSAENETUNREACH ENETUNREACH
|
|
103
|
+
#define WSAENETRESET ENETRESET
|
|
104
|
+
#define WSAECONNABORTED ECONNABORTED
|
|
105
|
+
#define WSAECONNRESET ECONNRESET
|
|
106
|
+
#define WSAENOBUFS ENOBUFS
|
|
107
|
+
#define WSAEISCONN EISCONN
|
|
108
|
+
#define WSAENOTCONN ENOTCONN
|
|
109
|
+
#define WSAESHUTDOWN ESHUTDOWN
|
|
110
|
+
#define WSAETOOMANYREFS ETOOMANYREFS
|
|
111
|
+
#define WSAETIMEDOUT ETIMEDOUT
|
|
112
|
+
#define WSAECONNREFUSED ECONNREFUSED
|
|
113
|
+
#define WSAELOOP ELOOP
|
|
114
|
+
#define WSAENAMETOOLONG ENAMETOOLONG
|
|
115
|
+
#define WSAEHOSTDOWN EHOSTDOWN
|
|
116
|
+
#define WSAEHOSTUNREACH EHOSTUNREACH
|
|
117
|
+
#define WSAENOTEMPTY ENOTEMPTY
|
|
118
|
+
#define WSAEUSERS EUSERS
|
|
119
|
+
#define WSAEDQUOT EDQUOT
|
|
120
|
+
#define WSAESTALE ESTALE
|
|
121
|
+
#define WSAEREMOTE EREMOTE
|
|
122
|
+
#endif
|
|
123
|
+
|
|
124
|
+
#define WSAEINVALIDADDRESS 12001
|
|
125
|
+
|
|
126
|
+
#define ICmpBufferSize 4096
|
|
127
|
+
typedef byte TIcmpBuffer[ICmpBufferSize];
|
|
128
|
+
|
|
129
|
+
// Ping result
|
|
130
|
+
#define PR_CANNOT_PERFORM -1 // cannot ping :
|
|
131
|
+
// unix : no root rights or SUID flag set to
|
|
132
|
+
// open raw sockets
|
|
133
|
+
// windows : neither helper DLL found nor raw
|
|
134
|
+
// sockets can be opened (no administrator rights)
|
|
135
|
+
// In this case the execution continues whitout
|
|
136
|
+
// the benefit of the smart-connect.
|
|
137
|
+
|
|
138
|
+
#define PR_SUCCESS 0 // Host found
|
|
139
|
+
#define PR_ERROR 1 // Ping Error, Ping was performed but ...
|
|
140
|
+
// - host didn't replied (not found)
|
|
141
|
+
// - routing error
|
|
142
|
+
// - TTL expired
|
|
143
|
+
// - ... all other icmp error that we don't need
|
|
144
|
+
// to know.
|
|
145
|
+
|
|
146
|
+
// Ping Kind
|
|
147
|
+
#define pkCannotPing 1 // see PR_CANNOT_PERFORM comments
|
|
148
|
+
#define pkWinHelper 2 // use iphlpapi.dll (only windows)
|
|
149
|
+
#define pkRawSocket 3 // use raw sockets (unix/windows)
|
|
150
|
+
|
|
151
|
+
const byte ICMP_ECHORP = 0; // ECHO Reply
|
|
152
|
+
const byte ICMP_ECHORQ = 8; // ECHO Request
|
|
153
|
+
//---------------------------------------------------------------------------
|
|
154
|
+
// RAW SOCKET PING STRUCTS
|
|
155
|
+
//---------------------------------------------------------------------------
|
|
156
|
+
#pragma pack(1)
|
|
157
|
+
typedef struct{
|
|
158
|
+
byte ip_hl_v;
|
|
159
|
+
byte ip_tos;
|
|
160
|
+
word ip_len;
|
|
161
|
+
word ip_id ;
|
|
162
|
+
word ip_off;
|
|
163
|
+
byte ip_ttl;
|
|
164
|
+
byte ip_p;
|
|
165
|
+
word ip_sum;
|
|
166
|
+
longword ip_src;
|
|
167
|
+
longword ip_dst;
|
|
168
|
+
}TIPHeader;
|
|
169
|
+
|
|
170
|
+
typedef struct{
|
|
171
|
+
byte ic_type; // Type of message
|
|
172
|
+
byte ic_code; // Code
|
|
173
|
+
word ic_cksum; // 16 bit checksum
|
|
174
|
+
word ic_id; // ID (ic1 : ipv4)
|
|
175
|
+
word ic_seq; // Sequence
|
|
176
|
+
}TIcmpHeader;
|
|
177
|
+
|
|
178
|
+
typedef struct{
|
|
179
|
+
TIcmpHeader Header;
|
|
180
|
+
byte Data[32]; // use the well known default
|
|
181
|
+
}TIcmpPacket, *PIcmpPacket;
|
|
182
|
+
|
|
183
|
+
typedef struct{
|
|
184
|
+
TIPHeader IPH;
|
|
185
|
+
TIcmpPacket ICmpReply;
|
|
186
|
+
}TIcmpReply, *PIcmpReply;
|
|
187
|
+
#pragma pack()
|
|
188
|
+
|
|
189
|
+
//---------------------------------------------------------------------------
|
|
190
|
+
class TRawSocketPinger
|
|
191
|
+
{
|
|
192
|
+
private:
|
|
193
|
+
socket_t FSocket;
|
|
194
|
+
PIcmpPacket SendPacket;
|
|
195
|
+
TIcmpBuffer IcmpBuffer;
|
|
196
|
+
word FId, FSeq;
|
|
197
|
+
void InitPacket();
|
|
198
|
+
word PacketChecksum();
|
|
199
|
+
bool CanRead(int Timeout);
|
|
200
|
+
public:
|
|
201
|
+
bool Ping(longword ip_addr, int Timeout);
|
|
202
|
+
TRawSocketPinger();
|
|
203
|
+
~TRawSocketPinger();
|
|
204
|
+
};
|
|
205
|
+
typedef TRawSocketPinger *PRawSocketPinger;
|
|
206
|
+
//---------------------------------------------------------------------------
|
|
207
|
+
class TPinger
|
|
208
|
+
{
|
|
209
|
+
private:
|
|
210
|
+
PRawSocketPinger RawPinger;
|
|
211
|
+
bool RawAvail;
|
|
212
|
+
#ifdef OS_WINDOWS
|
|
213
|
+
bool WinPing(longword ip_addr, int Timeout);
|
|
214
|
+
#endif
|
|
215
|
+
bool RawPing(longword ip_addr, int Timeout);
|
|
216
|
+
public:
|
|
217
|
+
TPinger();
|
|
218
|
+
~TPinger();
|
|
219
|
+
bool Ping(char *Host, int Timeout);
|
|
220
|
+
bool Ping(longword ip_addr, int Timeout);
|
|
221
|
+
};
|
|
222
|
+
typedef TPinger *PPinger;
|
|
223
|
+
//---------------------------------------------------------------------------
|
|
224
|
+
class TSnapBase // base class endian-aware
|
|
225
|
+
{
|
|
226
|
+
private:
|
|
227
|
+
bool LittleEndian;
|
|
228
|
+
protected:
|
|
229
|
+
longword SwapDWord(longword Value);
|
|
230
|
+
word SwapWord(word Value);
|
|
231
|
+
public:
|
|
232
|
+
TSnapBase();
|
|
233
|
+
};
|
|
234
|
+
//---------------------------------------------------------------------------
|
|
235
|
+
class TMsgSocket : public TSnapBase
|
|
236
|
+
{
|
|
237
|
+
private:
|
|
238
|
+
PPinger Pinger;
|
|
239
|
+
int GetLastSocketError();
|
|
240
|
+
int SockCheck(int SockResult);
|
|
241
|
+
void DestroySocket();
|
|
242
|
+
void SetSocketOptions();
|
|
243
|
+
bool CanWrite(int Timeout);
|
|
244
|
+
void GetLocal();
|
|
245
|
+
void GetRemote();
|
|
246
|
+
void SetSin(sockaddr_in &sin, char *Address, u_short Port);
|
|
247
|
+
void GetSin(sockaddr_in sin, char *Address, u_short &Port);
|
|
248
|
+
protected:
|
|
249
|
+
socket_t FSocket;
|
|
250
|
+
sockaddr_in LocalSin;
|
|
251
|
+
sockaddr_in RemoteSin;
|
|
252
|
+
//--------------------------------------------------------------------------
|
|
253
|
+
// low level socket
|
|
254
|
+
void CreateSocket();
|
|
255
|
+
// Called when a socket is assigned externally
|
|
256
|
+
void GotSocket();
|
|
257
|
+
// Returns how many bytes are ready to be read in the winsock buffer
|
|
258
|
+
int WaitingData();
|
|
259
|
+
// Waits until there at least "size" bytes ready to be read or until receive timeout occurs
|
|
260
|
+
int WaitForData(int Size, int Timeout);
|
|
261
|
+
// Clear socket input buffer
|
|
262
|
+
void Purge();
|
|
263
|
+
public:
|
|
264
|
+
longword ClientHandle;
|
|
265
|
+
longword LocalBind;
|
|
266
|
+
// Coordinates Address:Port
|
|
267
|
+
char LocalAddress[16];
|
|
268
|
+
char RemoteAddress[16];
|
|
269
|
+
word LocalPort;
|
|
270
|
+
word RemotePort;
|
|
271
|
+
// "speed" of the socket listener (used server-side)
|
|
272
|
+
int WorkInterval;
|
|
273
|
+
// Timeouts : 3 different values for fine tuning.
|
|
274
|
+
// Send timeout should be small since with work with small packets and TCP_NO_DELAY
|
|
275
|
+
// option, so we don't expect "time to wait".
|
|
276
|
+
// Recv timeout depends of equipment's processing time : we send a packet, the equipment
|
|
277
|
+
// processes the message, finally it sends the answer. In any case Recv timeout > Send Timeout.
|
|
278
|
+
// PingTimeout is the maximum time interval during which we expect that the PLC answers.
|
|
279
|
+
// By default is 750 ms, increase it if there are many switch/repeaters.
|
|
280
|
+
int PingTimeout;
|
|
281
|
+
int RecvTimeout;
|
|
282
|
+
int SendTimeout;
|
|
283
|
+
//int ConnTimeout;
|
|
284
|
+
// Output : Last operation error
|
|
285
|
+
int LastTcpError;
|
|
286
|
+
// Output : Connected to the remote Host/Peer/Client
|
|
287
|
+
bool Connected;
|
|
288
|
+
//--------------------------------------------------------------------------
|
|
289
|
+
TMsgSocket();
|
|
290
|
+
virtual ~TMsgSocket();
|
|
291
|
+
// Returns true if "something" can be read during the Timeout interval..
|
|
292
|
+
bool CanRead(int Timeout);
|
|
293
|
+
// Connects to a peer (using RemoteAddress and RemotePort)
|
|
294
|
+
int SckConnect(); // (client-side)
|
|
295
|
+
// Disconnects from a peer (gracefully)
|
|
296
|
+
void SckDisconnect();
|
|
297
|
+
// Disconnects RAW
|
|
298
|
+
void ForceClose();
|
|
299
|
+
// Binds to a local adapter (using LocalAddress and LocalPort) (server-side)
|
|
300
|
+
int SckBind();
|
|
301
|
+
// Listens for an incoming connection (server-side)
|
|
302
|
+
int SckListen();
|
|
303
|
+
// Set an external socket reference (tipically from a listener)
|
|
304
|
+
void SetSocket(socket_t s);
|
|
305
|
+
// Accepts an incoming connection returning a socket descriptor (server-side)
|
|
306
|
+
socket_t SckAccept();
|
|
307
|
+
// Pings the peer before connecting
|
|
308
|
+
bool Ping(char *Host);
|
|
309
|
+
bool Ping(sockaddr_in Addr);
|
|
310
|
+
// Sends a packet
|
|
311
|
+
int SendPacket(void *Data, int Size);
|
|
312
|
+
// Returns true if a Packet at least of "Size" bytes is ready to be read
|
|
313
|
+
bool PacketReady(int Size);
|
|
314
|
+
// Receives everything
|
|
315
|
+
int Receive(void *Data, int BufSize, int & SizeRecvd);
|
|
316
|
+
// Receives a packet of size specified.
|
|
317
|
+
int RecvPacket(void *Data, int Size);
|
|
318
|
+
// Peeks a packet of size specified without extract it from the socket queue
|
|
319
|
+
int PeekPacket(void *Data, int Size);
|
|
320
|
+
virtual bool Execute();
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
typedef TMsgSocket *PMsgSocket;
|
|
324
|
+
//---------------------------------------------------------------------------
|
|
325
|
+
void Msg_CloseSocket(socket_t FSocket);
|
|
326
|
+
longword Msg_GetSockAddr(socket_t FSocket);
|
|
327
|
+
//---------------------------------------------------------------------------
|
|
328
|
+
class SocketsLayer
|
|
329
|
+
{
|
|
330
|
+
private:
|
|
331
|
+
#ifdef OS_WINDOWS
|
|
332
|
+
WSADATA wsaData;
|
|
333
|
+
#endif
|
|
334
|
+
public:
|
|
335
|
+
SocketsLayer();
|
|
336
|
+
~SocketsLayer();
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
#endif // snap_msgsock_h
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.4.1 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#ifndef snap_platform_h
|
|
27
|
+
#define snap_platform_h
|
|
28
|
+
//---------------------------------------------------------------------------
|
|
29
|
+
#if defined (_WIN32)|| defined(_WIN64)|| defined(__WIN32__) || defined(__WINDOWS__)
|
|
30
|
+
# define OS_WINDOWS
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
// Visual Studio needs this to use the correct time_t size
|
|
34
|
+
#if defined (_WIN32) && !defined(_WIN64) && !defined(_EMBEDDING_VS2013UP)
|
|
35
|
+
# define _USE_32BIT_TIME_T
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
// Linux, BSD and Solaris define "unix", OSX doesn't, even though it derives from BSD
|
|
39
|
+
#if defined(unix) || defined(__unix__) || defined(__unix)
|
|
40
|
+
# define PLATFORM_UNIX
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#if BSD>=0
|
|
44
|
+
# define OS_BSD
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#if __APPLE__
|
|
48
|
+
# define OS_OSX
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
#if defined(__SVR4) || defined(__svr4__)
|
|
52
|
+
# define OS_SOLARIS
|
|
53
|
+
// Thanks to Rolf Stalder now it's possible to use pthreads also for Solaris
|
|
54
|
+
// In any case the Solaris native threads model is still present and can be
|
|
55
|
+
// used uncommenting the #define line below.
|
|
56
|
+
# undef OS_SOLARIS_NATIVE_THREADS
|
|
57
|
+
// # define OS_SOLARIS_NATIVE_THREADS
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#if defined(PLATFORM_UNIX)
|
|
61
|
+
# include <unistd.h>
|
|
62
|
+
# include <sys/param.h>
|
|
63
|
+
# if defined(_POSIX_VERSION)
|
|
64
|
+
# define POSIX
|
|
65
|
+
# endif
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#ifdef OS_OSX
|
|
69
|
+
# include <unistd.h>
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#if (!defined (OS_WINDOWS)) && (!defined(PLATFORM_UNIX)) && (!defined(OS_BSD)) && (!defined(OS_OSX))
|
|
73
|
+
# error platform still unsupported (please add it yourself and report ;-)
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
// Visual C++ not C99 compliant (VS2008--)
|
|
77
|
+
#ifdef _MSC_VER
|
|
78
|
+
# if _MSC_VER >= 1600
|
|
79
|
+
# include <stdint.h> // VS2010++ have it
|
|
80
|
+
# else
|
|
81
|
+
typedef signed __int8 int8_t;
|
|
82
|
+
typedef signed __int16 int16_t;
|
|
83
|
+
typedef signed __int32 int32_t;
|
|
84
|
+
typedef signed __int64 int64_t;
|
|
85
|
+
typedef unsigned __int8 uint8_t;
|
|
86
|
+
typedef unsigned __int16 uint16_t;
|
|
87
|
+
typedef unsigned __int32 uint32_t;
|
|
88
|
+
typedef unsigned __int64 uint64_t;
|
|
89
|
+
#ifdef _WIN64
|
|
90
|
+
typedef unsigned __int64 uintptr_t;
|
|
91
|
+
#else
|
|
92
|
+
typedef unsigned __int32 uintptr_t;
|
|
93
|
+
#endif
|
|
94
|
+
# endif
|
|
95
|
+
#else
|
|
96
|
+
# include <stdint.h>
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
#include <time.h>
|
|
100
|
+
#include <cstring>
|
|
101
|
+
#include <stdlib.h>
|
|
102
|
+
|
|
103
|
+
#ifdef OS_WINDOWS
|
|
104
|
+
# define WIN32_LEAN_AND_MEAN
|
|
105
|
+
# include <windows.h>
|
|
106
|
+
# include <winsock2.h>
|
|
107
|
+
# include <mmsystem.h>
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
#ifdef OS_SOLARIS
|
|
111
|
+
# include <sys/filio.h>
|
|
112
|
+
# include <cstdlib>
|
|
113
|
+
# include <string.h>
|
|
114
|
+
#endif
|
|
115
|
+
|
|
116
|
+
#if defined(PLATFORM_UNIX) || defined(OS_OSX)
|
|
117
|
+
# include <errno.h>
|
|
118
|
+
# include <sys/time.h>
|
|
119
|
+
# include <sys/socket.h>
|
|
120
|
+
# include <arpa/inet.h>
|
|
121
|
+
# include <netinet/tcp.h>
|
|
122
|
+
# include <netinet/in.h>
|
|
123
|
+
# include <sys/ioctl.h>
|
|
124
|
+
#endif
|
|
125
|
+
|
|
126
|
+
#ifdef OS_WINDOWS
|
|
127
|
+
# define EXPORTSPEC extern "C" __declspec ( dllexport )
|
|
128
|
+
# define S7API __stdcall
|
|
129
|
+
#else
|
|
130
|
+
# define EXPORTSPEC extern "C"
|
|
131
|
+
# define S7API
|
|
132
|
+
#endif
|
|
133
|
+
|
|
134
|
+
// Exact length types regardless of platform/processor
|
|
135
|
+
// We absolute need of them, all structs have an exact size that
|
|
136
|
+
// must be the same across the processor used 32/64 bit
|
|
137
|
+
|
|
138
|
+
// *Use them* if you change/expand the code and avoid long, u_long and so on...
|
|
139
|
+
|
|
140
|
+
typedef uint8_t byte;
|
|
141
|
+
typedef uint16_t word;
|
|
142
|
+
typedef uint32_t longword;
|
|
143
|
+
typedef byte *pbyte;
|
|
144
|
+
typedef word *pword;
|
|
145
|
+
typedef uintptr_t snap_obj; // multi platform/processor object reference
|
|
146
|
+
|
|
147
|
+
#ifndef OS_WINDOWS
|
|
148
|
+
# define INFINITE 0XFFFFFFFF
|
|
149
|
+
#endif
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
#endif // snap_platform_h
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
|
|
27
|
+
#include "snap_sysutils.h"
|
|
28
|
+
|
|
29
|
+
#ifdef OS_OSX
|
|
30
|
+
int clock_gettime(int clk_id, struct timespec* t)
|
|
31
|
+
{
|
|
32
|
+
struct timeval now;
|
|
33
|
+
int rv = gettimeofday(&now, NULL);
|
|
34
|
+
if (rv) return rv;
|
|
35
|
+
t->tv_sec = now.tv_sec;
|
|
36
|
+
t->tv_nsec = now.tv_usec * 1000;
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
//---------------------------------------------------------------------------
|
|
42
|
+
longword SysGetTick()
|
|
43
|
+
{
|
|
44
|
+
#ifdef OS_WINDOWS
|
|
45
|
+
return timeGetTime();
|
|
46
|
+
#else
|
|
47
|
+
struct timespec ts;
|
|
48
|
+
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
49
|
+
return (longword) (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
|
|
50
|
+
#endif
|
|
51
|
+
}
|
|
52
|
+
//---------------------------------------------------------------------------
|
|
53
|
+
void SysSleep(longword Delay_ms)
|
|
54
|
+
{
|
|
55
|
+
#ifdef OS_WINDOWS
|
|
56
|
+
Sleep(Delay_ms);
|
|
57
|
+
#else
|
|
58
|
+
struct timespec ts;
|
|
59
|
+
ts.tv_sec = (time_t)(Delay_ms / 1000);
|
|
60
|
+
ts.tv_nsec =(long)((Delay_ms - ts.tv_sec) * 1000000);
|
|
61
|
+
nanosleep(&ts, (struct timespec *)0);
|
|
62
|
+
#endif
|
|
63
|
+
}
|
|
64
|
+
//---------------------------------------------------------------------------
|
|
65
|
+
longword DeltaTime(longword &Elapsed)
|
|
66
|
+
{
|
|
67
|
+
longword TheTime;
|
|
68
|
+
TheTime=SysGetTick();
|
|
69
|
+
// Checks for rollover
|
|
70
|
+
if (TheTime<Elapsed)
|
|
71
|
+
Elapsed=0;
|
|
72
|
+
return TheTime-Elapsed;
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#ifndef snap_sysutils_h
|
|
27
|
+
#define snap_sysutils_h
|
|
28
|
+
//---------------------------------------------------------------------------
|
|
29
|
+
#include "snap_platform.h"
|
|
30
|
+
//---------------------------------------------------------------------------
|
|
31
|
+
#if defined(OS_OSX) && !defined(CLOCK_MONOTONIC)
|
|
32
|
+
# define CLOCK_MONOTONIC 0
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
longword SysGetTick();
|
|
36
|
+
void SysSleep(longword Delay_ms);
|
|
37
|
+
longword DeltaTime(longword &Elapsed);
|
|
38
|
+
|
|
39
|
+
#endif // snap_sysutils_h
|