Commit 83308b83 authored by Lucas Russo's avatar Lucas Russo

src/libs/libbpmclient/*: update MDP to MLM protocol

The MDP protocol is now unmaintained and not suitable for deployment
as the error cases are not handled correctly. Moreover, the MDP
reference design is not following CZMQ 3.0.0 series.
parent 79c53fc4
......@@ -67,7 +67,7 @@ CFLAGS_PLATFORM = -Wall -Wextra -Werror
LDFLAGS_PLATFORM =
# Libraries
LIBS = -lzmq -lczmq -lmdp
LIBS = -lzmq -lczmq -lmlm
# General library flags -L<libdir>
LFLAGS =
......
......@@ -4,6 +4,6 @@ Project Dependencies:
libdisptable
Foreign Dependencies:
libmdp
libmlm
libczmq
libzmq
......@@ -39,6 +39,7 @@
bpm_client_err_str (err_type))
#define BPMCLIENT_DFLT_LOG_MODE "w"
#define BPMCLIENT_MLM_CONNECT_TIMEOUT 1000 /* in ms */
static bpm_client_t *_bpm_client_new (char *broker_endp, int verbose,
const char *log_file_name, const char *log_mode);
......@@ -104,7 +105,8 @@ void bpm_client_destroy (bpm_client_t **self_p)
bpm_client_t *self = *self_p;
self->acq_chan = NULL;
mdp_client_destroy (&self->mdp_client);
mlm_client_destroy (&self->mlm_client);
zuuid_destroy (&self->uuid);
free (self);
*self_p = NULL;
}
......@@ -114,6 +116,8 @@ void bpm_client_destroy (bpm_client_t **self_p)
static bpm_client_t *_bpm_client_new (char *broker_endp, int verbose,
const char *log_file_name, const char *log_mode)
{
(void) verbose;
assert (broker_endp);
/* Set logfile available for all dev_mngr and dev_io instances.
......@@ -126,16 +130,30 @@ static bpm_client_t *_bpm_client_new (char *broker_endp, int verbose,
bpm_client_t *self = zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->mdp_client = mdp_client_new (broker_endp, verbose);
ASSERT_TEST(self->mdp_client!=NULL, "Could not create MDP client",
err_mdp_client);
/* Generate UUID to work with MLM broker */
self->uuid = zuuid_new ();
ASSERT_ALLOC(self->uuid, err_uuid_alloc);
self->mlm_client = mlm_client_new ();
ASSERT_TEST(self->mlm_client!=NULL, "Could not create MLM client",
err_mlm_client);
/* Connect to broker with current UUID address in canonical form */
int rc = mlm_client_connect (self->mlm_client, broker_endp,
BPMCLIENT_MLM_CONNECT_TIMEOUT, zuuid_str_canonical (self->uuid));
ASSERT_TEST(rc >= 0, "Could not connect MLM client to broker", err_mlm_connect);
/* Initialize acquisition table */
self->acq_chan = acq_chan;
return self;
err_mdp_client:
err_mlm_connect:
mlm_client_destroy (&self->mlm_client);
err_mlm_client:
zuuid_destroy (&self->uuid);
err_uuid_alloc:
free (self);
err_self_alloc:
return NULL;
......@@ -170,10 +188,10 @@ bpm_client_err_e bpm_func_exec (bpm_client_t *self, const disp_op_t *func, char
input += in_size;
}
mdp_client_send (self->mdp_client, service, &msg);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &msg);
/* Receive report */
zmsg_t *report = mdp_client_recv (self->mdp_client, NULL, NULL);
zmsg_t *report = mlm_client_recv (self->mlm_client);
ASSERT_TEST(report != NULL, "Report received is NULL", err_msg);
/* Message is:
......@@ -267,7 +285,7 @@ bpm_client_err_e bpm_blink_leds (bpm_client_t *self, char *service, uint32_t led
ASSERT_ALLOC(request, err_send_msg_alloc, BPM_CLIENT_ERR_ALLOC);
zmsg_addmem (request, &operation, sizeof (operation));
zmsg_addmem (request, &leds, sizeof (leds));
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
err_send_msg_alloc:
return err;
......@@ -323,7 +341,7 @@ bpm_client_err_e bpm_ad9510_cfg_defaults (bpm_client_t *self, char *service)
zmsg_t *request = zmsg_new ();
ASSERT_ALLOC(request, err_send_msg_alloc, BPM_CLIENT_ERR_ALLOC);
zmsg_addmem (request, &operation, sizeof (operation));
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
err_send_msg_alloc:
return err;
......@@ -851,10 +869,10 @@ static bpm_client_err_e _bpm_data_acquire (bpm_client_t *self, char *service,
zmsg_addmem (request, &operation, sizeof (operation));
zmsg_addmem (request, &acq_req->num_samples, sizeof (acq_req->num_samples));
zmsg_addmem (request, &acq_req->chan, sizeof (acq_req->chan));
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
/* Receive report */
zmsg_t *report = mdp_client_recv (self->mdp_client, NULL, NULL);
zmsg_t *report = mlm_client_recv (self->mlm_client);
ASSERT_TEST(report != NULL, "Report received is NULL", err_null_report);
/* Message is:
......@@ -897,10 +915,10 @@ static bpm_client_err_e _bpm_check_data_acquire (bpm_client_t *self, char *servi
* frame 0: operation code */
zmsg_t *request = zmsg_new ();
zmsg_addmem (request, &operation, sizeof (operation));
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
/* Receive report */
zmsg_t *report = mdp_client_recv (self->mdp_client, NULL, NULL);
zmsg_t *report = mlm_client_recv (self->mlm_client);
ASSERT_TEST(report != NULL, "Report received is NULL", err_null_report);
/* Message is:
......@@ -995,10 +1013,10 @@ static bpm_client_err_e _bpm_get_data_block (bpm_client_t *self, char *service,
zmsg_addmem (request, &operation, sizeof (operation));
zmsg_addmem (request, &acq_trans->req.chan, sizeof (acq_trans->req.chan));
zmsg_addmem (request, &acq_trans->block.idx, sizeof (acq_trans->block.idx));
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
/* Receive report */
zmsg_t *report = mdp_client_recv (self->mdp_client, NULL, NULL);
zmsg_t *report = mlm_client_recv (self->mlm_client);
ASSERT_TEST(report != NULL, "Report received is NULL", err_null_report);
/* Message is:
......
......@@ -9,7 +9,7 @@
#define _BPM_CLIENT_H_
#include <inttypes.h>
#include <mdp.h>
#include <malamute.h>
#include "bpm_client_codes.h"
#include "bpm_client_err.h"
......@@ -19,7 +19,8 @@ struct _acq_chan_t;
/* Our structure */
struct _bpm_client_t {
mdp_client_t *mdp_client; /* Majordomo client instance */
zuuid_t * uuid; /* Client UUID */
mlm_client_t *mlm_client; /* Malamute client instance */
const struct _acq_chan_t *acq_chan; /* Acquisition buffer table */
};
......
......@@ -48,7 +48,7 @@ bpm_client_err_e param_client_send_gen_rw (bpm_client_t *self, char *service,
zmsg_addmem (request, &rw, sizeof (rw));
zmsg_addmem (request, param, size);
mdp_client_send (self->mdp_client, service, &request);
mlm_client_sendto (self->mlm_client, service, NULL, NULL, 0, &request);
err_send_msg_alloc:
err_param_null:
......@@ -64,7 +64,7 @@ bpm_client_err_e param_client_recv_rw (bpm_client_t *self, char *service,
bpm_client_err_e err = BPM_CLIENT_SUCCESS;
/* Receive report */
*report = mdp_client_recv (self->mdp_client, NULL, NULL);
*report = mlm_client_recv (self->mlm_client);
ASSERT_TEST(*report != NULL, "Could not receive message", err_null_msg,
BPM_CLIENT_ERR_SERVER);
......
......@@ -9,7 +9,7 @@
#define _BPM_CLIENT_RW_PARAM_H_
#include <inttypes.h>
#include <mdp.h>
#include <malamute.h>
#include "bpm_client_codes.h"
#include "bpm_client_rw_param_codes.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment