Formatted amsat/ to final coding guidelines

pull/1/head
Nate Bargmann 2017-10-08 07:08:53 -05:00
rodzic 62309abd49
commit 708ca78c77
1 zmienionych plików z 48 dodań i 37 usunięć

Wyświetl plik

@ -20,17 +20,18 @@
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> /* String function definitions */ #include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */ #include <unistd.h> /* UNIX standard function definitions */
#ifdef HAVE_SYS_IOCTL_H #ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h> # include <sys/ioctl.h>
#endif #endif
#include "hamlib/rotator.h" #include <hamlib/rotator.h>
#include "parallel.h" #include "parallel.h"
#include "misc.h" #include "misc.h"
#include "register.h" #include "register.h"
@ -48,8 +49,8 @@ if100_set_position(ROT *rot, azimuth_t az, elevation_t el)
rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el);
az_scale = 255./(rot->state.max_az - rot->state.min_az); az_scale = 255. / (rot->state.max_az - rot->state.min_az);
el_scale = 255./180; el_scale = 255. / 180;
az_i = (int)round((az - rot->state.min_az) * az_scale); az_i = (int)round((az - rot->state.min_az) * az_scale);
el_i = (int)round(el * el_scale); el_i = (int)round(el * el_scale);
@ -61,27 +62,37 @@ if100_set_position(ROT *rot, azimuth_t az, elevation_t el)
#define CLK 0x02 #define CLK 0x02
#define TRACK 0x08 #define TRACK 0x08
rig_debug(RIG_DEBUG_TRACE, "%s: shifting dataout 0x%04x to parallel port\n", __func__, dataout); rig_debug(RIG_DEBUG_TRACE,
"%s: shifting dataout 0x%04x to parallel port\n",
__func__, dataout);
retval = par_lock(port);
retval = par_lock (port);
if (retval != RIG_OK) if (retval != RIG_OK)
{
return retval; return retval;
}
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++)
if (dataout & 0x8000) { {
par_write_data(port, TRACK|DAT0); if (dataout & 0x8000)
par_write_data(port, TRACK|DAT0|CLK); {
par_write_data(port, TRACK|DAT0); par_write_data(port, TRACK | DAT0);
} else { par_write_data(port, TRACK | DAT0 | CLK);
par_write_data(port, TRACK | DAT0);
}
else
{
par_write_data(port, TRACK); par_write_data(port, TRACK);
par_write_data(port, TRACK|CLK); par_write_data(port, TRACK | CLK);
par_write_data(port, TRACK); par_write_data(port, TRACK);
} }
dataout = (dataout << 1) & 0xffff; dataout = (dataout << 1) & 0xffff;
} }
par_write_data(port, TRACK); par_write_data(port, TRACK);
par_unlock (port); par_unlock(port);
return RIG_OK; return RIG_OK;
} }
@ -89,26 +100,27 @@ if100_set_position(ROT *rot, azimuth_t az, elevation_t el)
/** IF-100 implements essentially only the set position function. /** IF-100 implements essentially only the set position function.
*/ */
const struct rot_caps if100_rot_caps = { const struct rot_caps if100_rot_caps =
.rot_model = ROT_MODEL_IF100, {
.model_name = "IF-100", .rot_model = ROT_MODEL_IF100,
.mfg_name = "AMSAT", .model_name = "IF-100",
.version = "0.1", .mfg_name = "AMSAT",
.copyright = "LGPL", .version = "0.1",
.status = RIG_STATUS_UNTESTED, .copyright = "LGPL",
.rot_type = ROT_TYPE_OTHER, .status = RIG_STATUS_UNTESTED,
.port_type = RIG_PORT_PARALLEL, .rot_type = ROT_TYPE_OTHER,
.write_delay = 0, .port_type = RIG_PORT_PARALLEL,
.post_write_delay = 0, .write_delay = 0,
.timeout = 200, .post_write_delay = 0,
.retry = 3, .timeout = 200,
.retry = 3,
.min_az = 0, .min_az = 0,
.max_az = 360, .max_az = 360,
.min_el = 0, .min_el = 0,
.max_el = 180, .max_el = 180,
.set_position = if100_set_position, .set_position = if100_set_position,
}; };
@ -116,10 +128,9 @@ const struct rot_caps if100_rot_caps = {
DECLARE_INITROT_BACKEND(amsat) DECLARE_INITROT_BACKEND(amsat)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rot_register(&if100_rot_caps); rot_register(&if100_rot_caps);
return RIG_OK; return RIG_OK;
} }