change TCP port datatype from int to uint16_t
because int doesn't match the range add range check in every TCP binary
This commit is contained in:
@ -1438,7 +1438,7 @@ mbus_context_serial(const char *device)
|
||||
}
|
||||
|
||||
mbus_handle *
|
||||
mbus_context_tcp(const char *host, int port)
|
||||
mbus_context_tcp(const char *host, uint16_t port)
|
||||
{
|
||||
mbus_handle *handle;
|
||||
mbus_tcp_data *tcp_data;
|
||||
@ -1655,7 +1655,7 @@ mbus_send_select_frame(mbus_handle * handle, const char *secondary_addr_str)
|
||||
// adressed slave(s) switch to the given baudrate
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, int baudrate)
|
||||
mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baudrate)
|
||||
{
|
||||
int retval = 0;
|
||||
int control_information = 0;
|
||||
|
@ -177,7 +177,7 @@ mbus_handle * mbus_context_serial(const char *device);
|
||||
*
|
||||
* @return Initialized "unified" handler when successful, NULL otherwise;
|
||||
*/
|
||||
mbus_handle * mbus_context_tcp(const char *host, int port);
|
||||
mbus_handle * mbus_context_tcp(const char *host, uint16_t port);
|
||||
|
||||
/**
|
||||
* Deallocate memory used by M-Bus context.
|
||||
@ -275,7 +275,7 @@ int mbus_send_application_reset_frame(mbus_handle * handle, int address, int sub
|
||||
*
|
||||
* @return Zero when successful.
|
||||
*/
|
||||
int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, int baudrate);
|
||||
int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baudrate);
|
||||
|
||||
/**
|
||||
* Sends request frame (REQ_UD2) to given slave using "unified" handle
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define _MBUS_PROTOCOL_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -95,7 +95,7 @@ mbus_serial_connect(mbus_handle *handle)
|
||||
// Set baud rate for serial connection
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
mbus_serial_set_baudrate(mbus_handle *handle, int baudrate)
|
||||
mbus_serial_set_baudrate(mbus_handle *handle, long baudrate)
|
||||
{
|
||||
speed_t speed;
|
||||
mbus_serial_data *serial_data;
|
||||
|
@ -37,7 +37,7 @@ int mbus_serial_connect(mbus_handle *handle);
|
||||
int mbus_serial_disconnect(mbus_handle *handle);
|
||||
int mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame);
|
||||
int mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame);
|
||||
int mbus_serial_set_baudrate(mbus_handle *handle, int baudrate);
|
||||
int mbus_serial_set_baudrate(mbus_handle *handle, long baudrate);
|
||||
void mbus_serial_data_free(mbus_handle *handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -38,7 +38,7 @@ mbus_tcp_connect(mbus_handle *handle)
|
||||
struct sockaddr_in s;
|
||||
struct timeval time_out;
|
||||
mbus_tcp_data *tcp_data;
|
||||
int port;
|
||||
uint16_t port;
|
||||
|
||||
if (handle == NULL)
|
||||
return -1;
|
||||
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
typedef struct _mbus_tcp_data
|
||||
{
|
||||
char *host;
|
||||
int port;
|
||||
uint16_t port;
|
||||
} mbus_tcp_data;
|
||||
|
||||
int mbus_tcp_connect(mbus_handle *handle);
|
||||
|
Reference in New Issue
Block a user