62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
/*
|
|
* This file is part of the libsidservo project.
|
|
* Copyright 2025 Edward V. Emelianov <edward.emelianoff@gmail.com>.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <usefull_macros.h>
|
|
|
|
#include "conf.h"
|
|
#include "serial.h"
|
|
#include "sidservo.h"
|
|
|
|
static int init(){
|
|
if(!Conf.EncoderPath || !Conf.EncoderSpeed){
|
|
WARNX("Define encoder device path and speed");
|
|
return FALSE;
|
|
}
|
|
if(!Conf.MountPath || !Conf.MountSpeed){
|
|
WARNX("Define mount device path and speed");
|
|
return FALSE;
|
|
}
|
|
if(!openEncoder(Conf.EncoderPath, Conf.EncoderSpeed)){
|
|
WARNX("Can't open %s with speed %d", Conf.EncoderPath, Conf.EncoderSpeed);
|
|
return FALSE;
|
|
}
|
|
if(!openMount(Conf.MountPath, Conf.MountSpeed)){
|
|
WARNX("Can't open %s with speed %d", Conf.MountPath, Conf.MountSpeed);
|
|
return FALSE;
|
|
}
|
|
// init RNG
|
|
srand48(sl_random_seed());
|
|
return TRUE;
|
|
}
|
|
|
|
static void quit(){
|
|
DBG("Close serial devices");
|
|
closeSerial();
|
|
DBG("Exit");
|
|
}
|
|
|
|
mount_t Mount = {
|
|
.readconf = readconf,
|
|
.dumpconf = dumpconf,
|
|
.helpandquit = help,
|
|
.init = init,
|
|
.quit = quit,
|
|
};
|