mirror of
https://github.com/emqx/neuron.git
synced 2026-10-31 08:29:03 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
369c5fb34a | ||
|
|
07d3b6eb08 | ||
|
|
e7f39c467f | ||
|
|
79665e140b | ||
|
|
2bef69d0ee | ||
|
|
dd62f111eb | ||
|
|
0f1b454c01 | ||
|
|
ed1dca302c | ||
|
|
83233ace32 | ||
|
|
f022427cb8 | ||
|
|
f8ae3a30c1 |
@@ -175,7 +175,7 @@ jobs:
|
||||
asset_name: ${{ matrix.type }}-${{ steps.get_version.outputs.version }}-daily-linux-${{ matrix.arch }}.${{ matrix.package }}
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
upload_daily_release_debug-asset:
|
||||
upload_daily_release_debug_asset:
|
||||
runs-on: ubuntu-20.04
|
||||
if: github.event_name == 'push'
|
||||
needs: create_daily_release
|
||||
@@ -223,7 +223,7 @@ jobs:
|
||||
|
||||
clean:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: upload_daily_release_asset
|
||||
needs: [upload_daily_release_asset, upload_daily_release_debug_asset]
|
||||
steps:
|
||||
- uses: geekyeggo/delete-artifact@v1
|
||||
with:
|
||||
|
||||
@@ -38,6 +38,8 @@ typedef enum neu_conn_tty_baud {
|
||||
NEU_CONN_TTY_BAUD_38400,
|
||||
NEU_CONN_TTY_BAUD_19200,
|
||||
NEU_CONN_TTY_BAUD_9600,
|
||||
NEU_CONN_TTY_BAUD_4800,
|
||||
NEU_CONN_TTY_BAUD_2400,
|
||||
} neu_conn_tty_baud_e;
|
||||
|
||||
typedef enum neu_conn_tty_parity {
|
||||
|
||||
@@ -79,16 +79,16 @@ int modbus_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group,
|
||||
} else {
|
||||
struct modbus_group_data *gd =
|
||||
(struct modbus_group_data *) group->user_data;
|
||||
plugin->plugin_group_data = gd;
|
||||
|
||||
for (uint16_t i = 0; i < gd->cmd_sort->n_cmd; i++) {
|
||||
uint16_t response_size = 0;
|
||||
int ret = modbus_stack_read(
|
||||
plugin->cmd_idx = i;
|
||||
int ret = modbus_stack_read(
|
||||
plugin->stack, gd->cmd_sort->cmd[i].slave_id,
|
||||
gd->cmd_sort->cmd[i].area, gd->cmd_sort->cmd[i].start_address,
|
||||
gd->cmd_sort->cmd[i].n_register, &response_size);
|
||||
if (ret > 0) {
|
||||
plugin->plugin_group_data = gd;
|
||||
plugin->cmd_idx = i;
|
||||
process_protocol_buf(plugin, response_size);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,16 @@ int modbus_value_handle(void *ctx, uint8_t slave_id, uint16_t n_byte,
|
||||
uint16_t start_address = gd->cmd_sort->cmd[plugin->cmd_idx].start_address;
|
||||
uint16_t n_register = gd->cmd_sort->cmd[plugin->cmd_idx].n_register;
|
||||
|
||||
if (bytes == NULL) {
|
||||
neu_dvalue_t dvalue = { 0 };
|
||||
|
||||
dvalue.type = NEU_TYPE_ERROR;
|
||||
dvalue.value.i32 = NEU_ERR_PLUGIN_DISCONNECTED;
|
||||
plugin->common.adapter_callbacks->driver.update(
|
||||
plugin->common.adapter, gd->group, NULL, dvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
utarray_foreach(gd->cmd_sort->cmd[plugin->cmd_idx].tags, modbus_point_t **,
|
||||
p_tag)
|
||||
{
|
||||
|
||||
@@ -113,6 +113,7 @@ int modbus_stack_read(modbus_stack_t *stack, uint8_t slave_id,
|
||||
{
|
||||
static __thread uint8_t buf[32] = { 0 };
|
||||
static __thread neu_protocol_pack_buf_t pbuf = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
neu_protocol_pack_buf_init(&pbuf, buf, sizeof(buf));
|
||||
|
||||
@@ -143,8 +144,12 @@ int modbus_stack_read(modbus_stack_t *stack, uint8_t slave_id,
|
||||
modbus_header_wrap(&pbuf, stack->seq++);
|
||||
*response_size += sizeof(struct modbus_header);
|
||||
|
||||
return stack->send_fn(stack->ctx, neu_protocol_pack_buf_used_size(&pbuf),
|
||||
neu_protocol_pack_buf_get(&pbuf));
|
||||
ret = stack->send_fn(stack->ctx, neu_protocol_pack_buf_used_size(&pbuf),
|
||||
neu_protocol_pack_buf_get(&pbuf));
|
||||
if (ret <= 0) {
|
||||
stack->value_fn(stack->ctx, 0, 0, NULL);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int modbus_stack_write(modbus_stack_t *stack, void *req, uint8_t slave_id,
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
size_t req_data_size = 0; \
|
||||
req_type *req = NULL; \
|
||||
\
|
||||
nng_aio_set_timeout(aio, 3000); \
|
||||
nng_aio_defer(aio, http_timeout, NULL); \
|
||||
if (http_get_body((aio), (void **) &req_data, &req_data_size) == 0 && \
|
||||
decode_fun(req_data, &req) == 0) { \
|
||||
{ func }; \
|
||||
|
||||
@@ -408,6 +408,7 @@ void http_timeout(nng_aio *aio, void *arg, int err)
|
||||
http_internal_error(aio, "{\"error\": \"canceled\"}");
|
||||
break;
|
||||
default:
|
||||
nlog_error("aio error: %d", err);
|
||||
http_internal_error(aio, "{\"error\": \"unknown\"}");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@ int http_unauthorized(nng_aio *aio, char *content);
|
||||
int http_not_found(nng_aio *aio, char *content);
|
||||
int http_conflict(nng_aio *aio, char *content);
|
||||
int http_internal_error(nng_aio *aio, char *content);
|
||||
void http_timeout(nng_aio *aio, void *arg, int err);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -637,6 +637,14 @@ static void conn_connect(neu_conn_t *conn)
|
||||
cfsetospeed(&tty_opt, B9600);
|
||||
cfsetispeed(&tty_opt, B9600);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_4800:
|
||||
cfsetospeed(&tty_opt, B4800);
|
||||
cfsetispeed(&tty_opt, B4800);
|
||||
break;
|
||||
case NEU_CONN_TTY_BAUD_2400:
|
||||
cfsetospeed(&tty_opt, B2400);
|
||||
cfsetispeed(&tty_opt, B2400);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (conn->param.params.tty_client.parity) {
|
||||
|
||||
Reference in New Issue
Block a user