Bi-monthly release with minor bug fixes and improvements
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
int LX200ZEQ25::audio_alert(const char * path)
{
system(path);
return 0;
}
audio_alert("mplayer '/home/goto_in_progress.wav'");
bool LX200ZEQ25::SetSlewRate(int index)
{
// Convert index to Meade format
//index = 3 - index;
if (isSimulation() == false && setZEQ25SlewMode(PortFD, index) < 0)
{
SlewRateSP.s = IPS_ALERT;
IDSetSwitch(&SlewRateSP, "Error setting slew mode.");
return false;
}
SlewRateSP.s = IPS_OK;
IDSetSwitch(&SlewRateSP, NULL);
return true;
}
int LX200ZEQ25::ZEQ25MoveTo(int fd, int direction)
{
DEBUGF(DBG_SCOPE, "<%s>", __FUNCTION__);
int nbytes_write=0;
switch (direction)
{
case LX200_NORTH:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":mn#");
tty_write_string(fd, ":mn#", &nbytes_write);
break;
case LX200_WEST:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":mw#");
tty_write_string(fd, ":mw#", &nbytes_write);
break;
case LX200_EAST:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":me#");
tty_write_string(fd, ":me#", &nbytes_write);
break;
case LX200_SOUTH:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":ms#");
tty_write_string(fd, ":ms#", &nbytes_write);
break;
default:
break;
}
tcflush(fd, TCIFLUSH);
return 0;
}
int LX200ZEQ25::setZEQ25SlewMode(int fd, int slewMode)
{
DEBUGF(DBG_SCOPE, "<%s>", __FUNCTION__);
int error_type;
int nbytes_write=0;
switch (slewMode)
{
case SLEW_MAX:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":SR9#");
if ( (error_type = tty_write_string(fd, ":SR9#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case SLEW_FIND:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":SR6#");
if ( (error_type = tty_write_string(fd, ":SR6#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case SLEW_CENTERING:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":SR4#");
if ( (error_type = tty_write_string(fd, ":SR4#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case SLEW_GUIDE:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":SR1#");
if ( (error_type = tty_write_string(fd, ":SR1#", &nbytes_write)) != TTY_OK)
return error_type;
break;
default:
break;
}
tcflush(fd, TCIFLUSH);
return 0;
}
bool LX200ZEQ25::MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
{
int current_move = (dir == DIRECTION_WEST) ? LX200_WEST : LX200_EAST;
switch (command)
{
case MOTION_START:
if (isSimulation() == false && ZEQ25MoveTo(PortFD, current_move) < 0)
{
DEBUG(INDI::Logger::DBG_ERROR, "Error setting W/E motion direction.");
return false;
}
else
DEBUGF(INDI::Logger::DBG_SESSION,"Moving to the %s.", (current_move == LX200_WEST) ? "West" : "East");
break;
case MOTION_STOP:
if (isSimulation() == false && ZEQ25HaltMovement(PortFD, current_move) < 0)
{
DEBUG(INDI::Logger::DBG_ERROR, "Error stopping W/E motion.");
return false;
}
else
DEBUGF(INDI::Logger::DBG_SESSION, "Movement to the %s halted.", (current_move == LX200_WEST) ? "West" : "East");
break;
}
return true;
}
bool LX200ZEQ25::MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
{
int current_move = (dir == DIRECTION_NORTH) ? LX200_NORTH : LX200_SOUTH;
switch (command)
{
case MOTION_START:
if (isSimulation() == false && ZEQ25MoveTo(PortFD, current_move) < 0)
{
DEBUG(INDI::Logger::DBG_ERROR, "Error setting N/S motion direction.");
return false;
}
else
DEBUGF(INDI::Logger::DBG_SESSION,"Moving to the %s.", (current_move == LX200_NORTH) ? "North" : "South");
break;
case MOTION_STOP:
if (isSimulation() == false && ZEQ25HaltMovement(PortFD, current_move) < 0)
{
DEBUG(INDI::Logger::DBG_ERROR, "Error stopping N/S motion.");
return false;
}
else
DEBUGF(INDI::Logger::DBG_SESSION, "Movement to the %s halted.", (current_move == LX200_NORTH) ? "North" : "South");
break;
}
return true;
}
int LX200ZEQ25::ZEQ25HaltMovement(int fd, int direction)
{
DEBUGF(DBG_SCOPE, "<%s>", __FUNCTION__);
int error_type;
int nbytes_write=0;
switch (direction)
{
case LX200_NORTH:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":q#");
if ( (error_type = tty_write_string(fd, ":q#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case LX200_WEST:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":q#");
if ( (error_type = tty_write_string(fd, ":q#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case LX200_EAST:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":q#");
if ( (error_type = tty_write_string(fd, ":q#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case LX200_SOUTH:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":q#");
if ( (error_type = tty_write_string(fd, ":q#", &nbytes_write)) != TTY_OK)
return error_type;
break;
case LX200_ALL:
DEBUGF(DBG_SCOPE, "CMD <%s>", ":q#");
if ( (error_type = tty_write_string(fd, ":q#", &nbytes_write)) != TTY_OK)
return error_type;
break;
default:
return -1;
break;
}
tcflush(fd, TCIFLUSH);
return 0;
}
bool LX200ZEQ25::Park()
{
DEBUGF(DBG_SCOPE, "<%s>", __FUNCTION__);
char slewNum[2];
int error_type;
int nbytes_write=0, nbytes_read=0;
DEBUGF(DBG_SCOPE, "CMD <%s>", ":MH#");
if ( (error_type = tty_write_string(PortFD, ":MH#", &nbytes_write)) != TTY_OK)
return false;
error_type = tty_read(PortFD, slewNum, 1, 3, &nbytes_read);
if (nbytes_read < 1)
{
DEBUGF(DBG_SCOPE, "RES ERROR <%d>", error_type);
return false;
}
/* We don't need to read the string message, just return corresponding error code */
tcflush(PortFD, TCIFLUSH);
DEBUGF(DBG_SCOPE, "RES <%c>", slewNum[0]);
ParkSP.s = IPS_BUSY;
TrackState = SCOPE_PARKING;
IDMessage(getDeviceName(), "Parking telescope in progress...");
audio_alert("mplayer '/home/mount_parking_in_progress.wav'");
return true;
}
bool LX200ZEQ25::UnPark()
{
if (ZEQ25_isHome())
{
SetParked(false);
TrackState = SCOPE_IDLE;
IDMessage(getDeviceName(), "Mount is unparked...");
return true;
}
IDMessage(getDeviceName(), "Error unparking Telescope");
return false;
}
bool LX200ZEQ25::ZEQ25_isHome()
{
char cmd[16];
int errcode = 0;
char errmsg[MAXRBUF];
char response[8];
int nbytes_read=0;
int nbytes_written=0;
strncpy(cmd, ":AH#", 16);
DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);
if ( (errcode = tty_write(PortFD, cmd, 4, &nbytes_written)) != TTY_OK)
{
tty_error_msg(errcode, errmsg, MAXRBUF);
DEBUGF(INDI::Logger::DBG_ERROR, "%s", errmsg);
return false;
}
if ( (errcode = tty_read(PortFD, response, 1, 3, &nbytes_read)))
{
tty_error_msg(errcode, errmsg, MAXRBUF);
DEBUGF(INDI::Logger::DBG_ERROR, "%s", errmsg);
return false;
}
if (nbytes_read > 0)
{
response[nbytes_read] = '\0';
DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", response);
tcflush(PortFD, TCIFLUSH);
if (response[0] == '1')
{
return true;
}
else
return false;
}
DEBUGF(INDI::Logger::DBG_ERROR, "Only received #%d bytes, expected 1.", nbytes_read);
return false;
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.