remove dependence of libusefull_macros
This commit is contained in:
@@ -18,44 +18,51 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <usefull_macros.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "dbg.h"
|
||||
#include "serial.h"
|
||||
#include "sidservo.h"
|
||||
|
||||
static int init(){
|
||||
if(!Conf.EncoderPath || !Conf.EncoderSpeed){
|
||||
WARNX("Define encoder device path and speed");
|
||||
return FALSE;
|
||||
conf_t Conf = {0};
|
||||
|
||||
/**
|
||||
* @brief init - open serial devices and do other job
|
||||
* @param c - initial configuration
|
||||
* @return error code
|
||||
*/
|
||||
static mcc_errcodes_t init(conf_t *c){
|
||||
if(!c) return MCC_E_BADFORMAT;
|
||||
Conf = *c;
|
||||
if(!Conf.EncoderPath || Conf.EncoderSpeed < 1200){
|
||||
DBG("Define encoder device path and speed");
|
||||
return MCC_E_BADFORMAT;
|
||||
}
|
||||
if(!Conf.MountPath || !Conf.MountSpeed){
|
||||
WARNX("Define mount device path and speed");
|
||||
return FALSE;
|
||||
if(!Conf.MountPath || Conf.MountSpeed < 1200){
|
||||
DBG("Define mount device path and speed");
|
||||
return MCC_E_BADFORMAT;
|
||||
}
|
||||
if(!openEncoder(Conf.EncoderPath, Conf.EncoderSpeed)){
|
||||
WARNX("Can't open %s with speed %d", Conf.EncoderPath, Conf.EncoderSpeed);
|
||||
return FALSE;
|
||||
DBG("Can't open %s with speed %d", Conf.EncoderPath, Conf.EncoderSpeed);
|
||||
return MCC_E_ENCODERDEV;
|
||||
}
|
||||
if(!openMount(Conf.MountPath, Conf.MountSpeed)){
|
||||
WARNX("Can't open %s with speed %d", Conf.MountPath, Conf.MountSpeed);
|
||||
return FALSE;
|
||||
DBG("Can't open %s with speed %d", Conf.MountPath, Conf.MountSpeed);
|
||||
return MCC_E_MOUNTDEV;
|
||||
}
|
||||
// init RNG
|
||||
srand48(sl_random_seed());
|
||||
return TRUE;
|
||||
return MCC_E_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief quit - close all opened and return to default state
|
||||
*/
|
||||
static void quit(){
|
||||
DBG("Close serial devices");
|
||||
closeSerial();
|
||||
DBG("Exit");
|
||||
}
|
||||
|
||||
// init mount class
|
||||
mount_t Mount = {
|
||||
.readconf = readconf,
|
||||
.dumpconf = dumpconf,
|
||||
.helpandquit = help,
|
||||
.init = init,
|
||||
.quit = quit,
|
||||
.getEnc = getEnc
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user