Rebuilding M-Bus context structs in progress

- changed local library file includes from <> to ""
- get rid of 'if (is_serial)' conditions
- mbus_context_serial() and mbus_context_tcp() allocates memory and initialize context specific function pointers
- simply mbus_connect() called instead of mbus_connect_tcp() or mbus_connect_serial()
- context specific data can still be accessed via (void* auxdata) pointer
- strdup(3) to copy host IP into TCP context struct
This commit is contained in:
jakubovsky
2012-07-04 17:18:36 +02:00
parent 9f9e0fc008
commit c848090f56
8 changed files with 223 additions and 212 deletions

21
mbus/mbus-serial.h Normal file → Executable file
View File

@ -19,23 +19,20 @@
#define MBUS_SERIAL_H
#include <termios.h>
#include <mbus/mbus.h>
typedef struct _mbus_serial_handle {
#include "mbus-protocol-aux.h"
#include "mbus-protocol.h"
typedef struct _mbus_serial_handle
{
char *device;
int fd;
struct termios t;
} mbus_serial_handle;
mbus_serial_handle *mbus_serial_connect(char *device);
int mbus_serial_disconnect(mbus_serial_handle *handle);
int mbus_serial_send_frame(mbus_serial_handle *handle, mbus_frame *frame);
int mbus_serial_recv_frame(mbus_serial_handle *handle, mbus_frame *frame);
int mbus_serial_set_baudrate(mbus_serial_handle *handle, int baudrate);
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);
#endif /* MBUS_SERIAL_H */