-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibmodbus.h
More file actions
147 lines (116 loc) · 4.31 KB
/
libmodbus.h
File metadata and controls
147 lines (116 loc) · 4.31 KB
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
/* Code generated by cmd/cgo; DO NOT EDIT. */
/* package modbus */
#line 1 "cgo-builtin-export-prolog"
#include <stddef.h>
#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif
#endif
/* Start of preamble from import "C" comments. */
#line 6 "binding.go"
#include <node_api.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
// Function declarations
napi_value NewModbusDeviceJS(napi_env env, napi_callback_info info);
napi_value ReadCoilsJS(napi_env env, napi_callback_info info);
napi_value ReadDiscreteInputsJS(napi_env env, napi_callback_info info);
napi_value ReadHoldingRegistersJS(napi_env env, napi_callback_info info);
napi_value ReadInputRegistersJS(napi_env env, napi_callback_info info);
napi_value WriteCoilJS(napi_env env, napi_callback_info info);
napi_value WriteRegisterJS(napi_env env, napi_callback_info info);
napi_value WriteMultipleCoilsJS(napi_env env, napi_callback_info info);
napi_value WriteMultipleRegistersJS(napi_env env, napi_callback_info info);
napi_value CloseJS(napi_env env, napi_callback_info info);
// Helper functions to convert types
static uint8_t get_uint8(napi_env env, napi_value value) {
uint32_t result;
napi_get_value_uint32(env, value, &result);
return (uint8_t)result;
}
static uint16_t get_uint16(napi_env env, napi_value value) {
uint32_t result;
napi_get_value_uint32(env, value, &result);
return (uint16_t)result;
}
// Helper function to create error
static napi_value create_error(napi_env env, const char* message) {
napi_value error_msg;
napi_create_string_utf8(env, message, strlen(message), &error_msg);
napi_value error;
napi_create_error(env, NULL, error_msg, &error);
return error;
}
// Helper function to create success response
static napi_value create_success(napi_env env) {
napi_value result;
napi_create_string_utf8(env, "success", 7, &result);
return result;
}
// Helper function to create function
static void create_function(napi_env env, napi_value exports, const char* name, napi_callback cb) {
napi_value fn;
napi_create_function(env, NULL, 0, cb, NULL, &fn);
napi_set_named_property(env, exports, name, fn);
}
#line 1 "cgo-generated-wrapper"
/* End of preamble from import "C" comments. */
/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"
#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H
typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef size_t GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
#ifdef _MSC_VER
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
#endif
/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
#endif
/* End of boilerplate cgo prologue. */
#ifdef __cplusplus
extern "C" {
#endif
extern napi_value NewModbusDeviceJS(napi_env env, napi_callback_info info);
extern napi_value ReadCoilsJS(napi_env env, napi_callback_info info);
extern napi_value ReadDiscreteInputsJS(napi_env env, napi_callback_info info);
extern napi_value ReadHoldingRegistersJS(napi_env env, napi_callback_info info);
extern napi_value ReadInputRegistersJS(napi_env env, napi_callback_info info);
extern napi_value WriteCoilJS(napi_env env, napi_callback_info info);
extern napi_value WriteRegisterJS(napi_env env, napi_callback_info info);
extern napi_value WriteMultipleCoilsJS(napi_env env, napi_callback_info info);
extern napi_value WriteMultipleRegistersJS(napi_env env, napi_callback_info info);
extern napi_value CloseJS(napi_env env, napi_callback_info info);
extern napi_value Init(napi_env env, napi_value exports);
#ifdef __cplusplus
}
#endif