Instrument Neutral Distributed Interface INDI  2.0.2
lacerta_mfoc_fmc.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2023 Christian Liska. All rights reserved.
3  based on the 2018 MFOC implementation (c) Franck Le Rhun and Christian Liska
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8  .
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13  .
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 *******************************************************************************/
19 
20 #include "lacerta_mfoc_fmc.h"
21 #include "indicom.h"
23 
24 #include <cmath>
25 #include <memory>
26 #include <cstring>
27 #include <unistd.h>
28 
29 // We declare an auto pointer to lacerta_mfoc_fmc.
30 static std::unique_ptr<lacerta_mfoc_fmc> Lacerta_mfoc_fmc(new lacerta_mfoc_fmc());
31 
32 // Delay for receiving messages
33 #define FOCUSMFOC_TIMEOUT 1000
34 // According to documentation for v2
35 #define MFOC_POSMAX_HARDWARE 250000
36 #define MFOC_POSMIN_HARDWARE 300
37 
38 /************************************************************************************
39  *
40 ************************************************************************************/
42 {
48 }
49 
50 /************************************************************************************
51  *
52 ************************************************************************************/
54 {
55  return "Lacerta MFOC FMC";
56 }
57 
58 /************************************************************************************
59  *
60 ************************************************************************************/
61 void lacerta_mfoc_fmc::ISGetProperties(const char *dev)
62 {
63  if (dev != nullptr && strcmp(dev, getDeviceName()) != 0)
64  return;
65 
67 
68  defineProperty(&TempTrackDirSP);
69  loadConfig(true, TempTrackDirSP.name);
70 
71  defineProperty(&StartSavedPositionSP);
72  loadConfig(true, StartSavedPositionSP.name);
73 }
74 
75 /************************************************************************************
76  *
77 ************************************************************************************/
79 {
81 
82  FocusBacklashN[0].min = 0;
83  FocusBacklashN[0].max = 255;
84  FocusBacklashN[0].step = 1;
85  FocusBacklashN[0].value = 12;
86 
87  IUFillNumber(&CurrentHoldingN[0], "CURRHOLD", "holding current mA", "%4d", 0, 1200, 1, 160);
88  IUFillNumberVector(&CurrentHoldingNP, CurrentHoldingN, 1, getDeviceName(), "CURRHOLD_SETTINGS", "Curr. Hold", FOCUS_TAB, IP_WO, 60,
89  IPS_IDLE);
90 
91  IUFillNumber(&CurrentMovingN[0], "CURRMOVE", "moving current mA", "%4d", 0, 1200, 1, 400);
92  IUFillNumberVector(&CurrentMovingNP, CurrentMovingN, 1, getDeviceName(), "CURRMOVE_SETTINGS", "Curr. Move", FOCUS_TAB, IP_WO, 60,
93  IPS_IDLE);
94 
97  FocusMaxPosN[0].step = (FocusMaxPosN[0].max - FocusMaxPosN[0].min) / 20.0;
98  FocusMaxPosN[0].value = 110000;
99 
100  FocusAbsPosN[0].min = 0;
101  FocusAbsPosN[0].max = FocusMaxPosN[0].value;
102  FocusAbsPosN[0].step = FocusAbsPosN[0].max / 50.0;
103 
104  IUFillSwitch(&TempTrackDirS[MODE_TDIR_BOTH], "Both", "Both", ISS_ON);
105  IUFillSwitch(&TempTrackDirS[MODE_TDIR_IN], "In", "In", ISS_ON);
106  IUFillSwitch(&TempTrackDirS[MODE_TDIR_OUT], "Out", "Out", ISS_ON);
107  IUFillSwitchVector(&TempTrackDirSP, TempTrackDirS, MODE_COUNT_TEMP_DIR, getDeviceName(), "Temp. dir.", "Temp. dir.",
109  ISR_1OFMANY, 60, IPS_IDLE);
110 
111  IUFillSwitch(&StartSavedPositionS[MODE_SAVED_ON], "Yes", "Yes", ISS_ON);
112  IUFillSwitch(&StartSavedPositionS[MODE_SAVED_OFF], "No", "No", ISS_OFF);
113  IUFillSwitchVector(&StartSavedPositionSP, StartSavedPositionS, MODE_COUNT_SAVED, getDeviceName(), "Start saved pos.",
114  "Start saved pos.", MAIN_CONTROL_TAB, IP_RW,
115  ISR_1OFMANY, 60, IPS_IDLE);
116 
117  return true;
118 }
119 
120 /************************************************************************************
121  *
122 ************************************************************************************/
124 {
125  // Get Initial Position before we define it in the INDI::Focuser class
126  FocusAbsPosN[0].value = GetAbsFocuserPosition();
127 
129 
130  if (isConnected())
131  {
132  defineProperty(&TempCompNP);
133  defineProperty(&CurrentHoldingNP);
134  defineProperty(&CurrentMovingNP);
135  defineProperty(&TempTrackDirSP);
136  defineProperty(&StartSavedPositionSP);
137 
138  }
139  else
140  {
141  deleteProperty(TempCompNP.name);
142  deleteProperty(CurrentHoldingNP.name);
143  deleteProperty(CurrentMovingNP.name);
144  deleteProperty(TempTrackDirSP.name);
145  deleteProperty(StartSavedPositionSP.name);
146  }
147 
148  return true;
149 }
150 
151 /************************************************************************************
152  *
153 ************************************************************************************/
155 {
156  char MFOC_cmd[32] = ": q #";
157  char MFOC_res[32] = {0};
158  char MFOC_res_type[32] = "0";
159  char device[5] = "0";
160  int MFOC_pos_measd = 0;
161  int nbytes_written = 0;
162  int nbytes_read = 0;
163 
164  bool device_found = false;
165  if (tty_write_string(PortFD, ": i #", &nbytes_written) == TTY_OK)
166  {
167  int count = 0;
168  do
169  {
170  try
171  {
172  if (tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read) != TTY_OK)
173  {
174  LOGF_ERROR("Unknown device or MFOC firmware not compatible with this driver version! Please update firmware! %s", device);
175  return false;
176  }
177 
178  sscanf(MFOC_res, "%s %s", MFOC_res_type, device);
179  LOGF_INFO("%s", device);
180  device_found = strcmp(device, "MFOC") == 0 || strcmp(device, "FMC") == 0;
181  } catch (...)
182  {
183  LOGF_ERROR("Cannot detect connected device %s", device);
184  return false;
185  }
186  count ++;
187  } while (!device_found && count != 10);
188  }
189  LOGF_INFO("Device detected: %s", device);
190 
191  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
192  LOGF_INFO("CMD: %s", MFOC_cmd);
193  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
194  MFOC_res[nbytes_read] = 0;
195  LOGF_DEBUG("Handshake: RES [%s]", MFOC_res);
196 
197  sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_pos_measd);
198 
199  if (MFOC_res_type[0] == 'p')
200  {
201  FocusAbsPosN[0].value = MFOC_pos_measd;
203  return true;
204  }
205 
206  return false;
207 }
208 
209 
210 /************************************************************************************
211  *
212 ************************************************************************************/
213 bool lacerta_mfoc_fmc::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
214 {
215  if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
216  {
217  // Temp. Track Direction
218  if (strcmp(TempTrackDirSP.name, name) == 0)
219  {
220  IUUpdateSwitch(&TempTrackDirSP, states, names, n);
221  int tdir = 0;
222  int index = IUFindOnSwitchIndex(&TempTrackDirSP);
223  char MFOC_cmd[32] = ": W ";
224  char MFOC_res[32] = {0};
225  int nbytes_read = 0;
226  int nbytes_written = 0;
227  int MFOC_tdir_measd = 0;
228  char MFOC_res_type[32] = "0";
229 
230  switch (index)
231  {
232  case MODE_TDIR_BOTH:
233  tdir = 0;
234  strcat(MFOC_cmd, "0 #");
235  break;
236 
237  case MODE_TDIR_IN:
238  tdir = 1;
239  strcat(MFOC_cmd, "1 #");
240  break;
241 
242  case MODE_TDIR_OUT:
243  tdir = 2;
244  strcat(MFOC_cmd, "2 #");
245  break;
246 
247  default:
248  TempTrackDirSP.s = IPS_ALERT;
249  IDSetSwitch(&TempTrackDirSP, "Unknown mode index %d", index);
250  return true;
251  }
252 
253 
254  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
255 
256  LOGF_DEBUG("ISNewSwitch: CMD [%s]", MFOC_cmd);
257  tty_write_string(PortFD, ": W #", &nbytes_written);
258  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
259  MFOC_res[nbytes_read] = 0;
260  sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tdir_measd);
261  LOGF_DEBUG("ISNewSwitch: RES [%s]", MFOC_res);
262 
263  if (MFOC_tdir_measd == tdir)
264  {
265  TempTrackDirSP.s = IPS_OK;
266  }
267  else
268  {
269  TempTrackDirSP.s = IPS_ALERT;
270  }
271 
272  IDSetSwitch(&TempTrackDirSP, nullptr);
273  return true;
274  }
275 
276  // Start at saved position
277  if (strcmp(StartSavedPositionSP.name, name) == 0)
278  {
279  IUUpdateSwitch(&StartSavedPositionSP, states, names, n);
280  int svstart = 0;
281  int index = IUFindOnSwitchIndex(&StartSavedPositionSP);
282  char MFOC_cmd[32] = ": N ";
283  char MFOC_res[32] = {0};
284  int nbytes_read = 0;
285  int nbytes_written = 0;
286  int MFOC_svstart_measd = 0;
287  char MFOC_res_type[32] = "0";
288 
289  switch (index)
290  {
291  case MODE_SAVED_ON:
292  svstart = 1;
293  strcat(MFOC_cmd, "1 #");
294  break;
295 
296  case MODE_SAVED_OFF:
297  svstart = 0;
298  strcat(MFOC_cmd, "0 #");
299  break;
300 
301  default:
302  StartSavedPositionSP.s = IPS_ALERT;
303  IDSetSwitch(&StartSavedPositionSP, "Unknown mode index %d", index);
304  return true;
305  }
306 
307  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
308 
309  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
310  tty_write_string(PortFD, ": N #", &nbytes_written);
311  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
312  MFOC_res[nbytes_read] = 0;
313  sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_svstart_measd);
314 
315  LOGF_DEBUG("RES [%s]", MFOC_res);
316  if (MFOC_svstart_measd == svstart)
317  {
318  StartSavedPositionSP.s = IPS_OK;
319  }
320  else
321  {
322  StartSavedPositionSP.s = IPS_ALERT;
323  }
324 
325  IDSetSwitch(&StartSavedPositionSP, nullptr);
326  return true;
327  }
328  }
329 
330  return INDI::Focuser::ISNewSwitch(dev, name, states, names, n);
331 }
332 
333 bool lacerta_mfoc_fmc::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
334 {
335  if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
336  {
337  if (strcmp(name, "TEMPCOMP_SETTINGS") == 0)
338  {
339  return SetTempComp(values, names, n);
340  }
341 
342  if (strcmp(name, "CURRHOLD_SETTINGS") == 0)
343  {
344  IUUpdateNumber(&CurrentHoldingNP, values, names, n);
345  if (!SetCurrHold(CurrentHoldingN[0].value))
346  {
347  CurrentHoldingNP.s = IPS_ALERT;
348  IDSetNumber(&CurrentHoldingNP, nullptr);
349  return false;
350  }
351  CurrentHoldingNP.s = IPS_OK;
352  IDSetNumber(&CurrentHoldingNP, nullptr);
353  return true;
354  }
355 
356  if (strcmp(name, "CURRMOVE_SETTINGS") == 0)
357  {
358  IUUpdateNumber(&CurrentMovingNP, values, names, n);
359  if (!SetCurrMove(CurrentMovingN[0].value))
360  {
361  CurrentMovingNP.s = IPS_ALERT;
362  IDSetNumber(&CurrentMovingNP, nullptr);
363  return false;
364  }
365  CurrentMovingNP.s = IPS_OK;
366  IDSetNumber(&CurrentMovingNP, nullptr);
367  return true;
368  }
369  }
370 
371  // Let INDI::Focuser handle any other number properties
372  return INDI::Focuser::ISNewNumber(dev, name, values, names, n);
373 }
374 
375 /************************************************************************************
376  *
377 ************************************************************************************/
379 {
380  char MFOC_cmd[32] = ": B ";
381  char MFOC_res[32] = {0};
382  int nbytes_read = 0;
383  int nbytes_written = 0;
384  int MFOC_tdir_measd = 0;
385  char bl_char[32] = {0};
386  char MFOC_res_type[32] = "0";
387 
388  sprintf(bl_char, "%d", steps);
389  strcat(bl_char, " #");
390  strcat(MFOC_cmd, bl_char);
391 
392  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
393  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
394 
395  tty_write_string(PortFD, ": b #", &nbytes_written);
396  do
397  {
398  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
399  MFOC_res[nbytes_read] = 0;
400  sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tdir_measd);
401  } while(strcmp("b", MFOC_res_type) != 0);
402  LOGF_DEBUG("RES [%s]", MFOC_res);
403 
404  return true;
405 }
406 
407 bool lacerta_mfoc_fmc::SetCurrHold(int currHoldValue)
408 {
409  char MFOC_cmd[32] = ": E ";
410  char MFOC_res[32] = {0};
411  int nbytes_read = 0;
412  int nbytes_written = 0;
413  int MFOC_ch_measd = 0;
414  char ch_char[32] = {0};
415  char MFOC_res_type[32] = "0";
416 
417  sprintf(ch_char, "%d", currHoldValue);
418  strcat(ch_char, " #");
419  strcat(MFOC_cmd, ch_char);
420 
421  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
422  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
423 
424  do
425  {
426  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
427  sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_ch_measd);
428  MFOC_res[nbytes_read] = 0;
429  } while(strcmp("e", MFOC_res_type) != 0);
430 
431  LOGF_DEBUG("RES [%s]", MFOC_res);
432  LOGF_INFO("Holding Current set to %d mA", MFOC_ch_measd);
433 
434  return true;
435 }
436 
437 bool lacerta_mfoc_fmc::SetCurrMove(int currMoveValue)
438 {
439  char MFOC_cmd[32] = ": F ";
440  char MFOC_res[32] = {0};
441  int nbytes_read = 0;
442  int nbytes_written = 0;
443  int MFOC_cm_measd = 0;
444  char cm_char[32] = {0};
445  char MFOC_res_type[32] = "0";
446 
447  sprintf(cm_char, "%d", currMoveValue);
448  strcat(cm_char, " #");
449  strcat(MFOC_cmd, cm_char);
450 
451  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
452  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
453 
454  do
455  {
456  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
457  sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_cm_measd);
458  MFOC_res[nbytes_read] = 0;
459  } while(strcmp("f", MFOC_res_type) != 0);
460 
461  LOGF_DEBUG("RES [%s]", MFOC_res);
462  LOGF_INFO("Moving Current set to %d mA", MFOC_cm_measd);
463 
464  return true;
465 }
466 
467 bool lacerta_mfoc_fmc::SetTempComp(double values[], char *names[], int n)
468 {
469  char MFOC_cmd[32] = ": U ";
470  char MFOC_res[32] = {0};
471  int nbytes_read = 0;
472  int nbytes_written = 0;
473  int MFOC_tc_measd = 0;
474  int tc_int = 0;
475  char tc_char[32] = {0};
476  char MFOC_res_type[32] = "0";
477 
478  TempCompNP.s = IPS_OK;
479  IUUpdateNumber(&TempCompNP, values, names, n);
480  tc_int = TempCompN[0].value;
481  sprintf(tc_char, "%d", tc_int);
482  strcat(tc_char, " #");
483  strcat(MFOC_cmd, tc_char);
484 
485  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
486  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
487 
488  tty_write_string(PortFD, ": u #", &nbytes_written);
489  do
490  {
491  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
492  MFOC_res[nbytes_read] = 0;
493  sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tc_measd);
494  } while(strcmp("u", MFOC_res_type) != 0);
495  LOGF_DEBUG("RES [%s]", MFOC_res);
496 
497  IDSetNumber(&TempCompNP, nullptr);
498 
499  return true;
500 }
501 
503 {
504  char MFOC_cmd[32] = ": G ";
505  char MFOC_res[32] = {0};
506  int nbytes_read = 0;
507  int nbytes_written = 0;
508  int MFOC_pm_measd = 0;
509  char pm_char[32] = {0};
510  char MFOC_res_type[32] = "0";
511 
512  sprintf(pm_char, "%d", ticks);
513  strcat(pm_char, " #");
514  strcat(MFOC_cmd, pm_char);
515 
516  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
517  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
518  IgnoreButLogResponse();
519 
520  tty_write_string(PortFD, ": g #", &nbytes_written);
521  do
522  {
523  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
524  MFOC_res[nbytes_read] = 0;
525  sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_pm_measd);
526  } while (strcmp("g", MFOC_res_type) != 0);
527  LOGF_DEBUG("RES [%s]", MFOC_res);
528 
529  return true;
530 }
531 
532 /************************************************************************************
533  *
534 ************************************************************************************/
536 {
537  char MFOC_cmd[32] = ": M ";
538  char abs_pos_char[32] = {0};
539  int nbytes_written = 0;
540 
541  //int pos = GetAbsFocuserPosition();
542  sprintf(abs_pos_char, "%d", targetTicks);
543  strcat(abs_pos_char, " #");
544  strcat(MFOC_cmd, abs_pos_char);
545 
546  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
547  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
548  IgnoreButLogResponse();
549 
550  FocusAbsPosN[0].value = targetTicks;
551 
552  GetAbsFocuserPosition();
553 
554  return IPS_OK;
555 }
556 
557 /************************************************************************************
558  *
559 ************************************************************************************/
561 {
562  // Calculation of the demand absolute position
563  auto targetTicks = std::clamp(FocusAbsPosN[0].value + (ticks * (dir == FOCUS_INWARD ? -1 : 1)), FocusAbsPosN[0].min, FocusAbsPosN[0].max);
564 
566  IDSetNumber(&FocusAbsPosNP, nullptr);
567 
568  return MoveAbsFocuser(targetTicks);
569 }
570 
571 /************************************************************************************
572  *
573 ************************************************************************************/
574 bool lacerta_mfoc_fmc::SyncFocuser(uint32_t ticks)
575 {
576  char MFOC_cmd[32] = ": P ";
577  char sync_pos[8] = {0};
578 
579  int nbytes_written = 0;
580 
581  sprintf(sync_pos, "%d", ticks);
582  strcat(sync_pos, " #");
583  strcat(MFOC_cmd, sync_pos);
584 
585  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
586  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
587  IgnoreButLogResponse();
588 
589  return true;
590 }
591 
592 /************************************************************************************
593  *
594 ************************************************************************************/
596 {
597  char MFOC_cmd[32] = ": H #";
598  char MFOC_res[32] = {0};
599  char MFOC_res_type[32] = "0";
600  int nbytes_read = 0;
601  int nbytes_written = 0;
602  int halt_flag = 0;
603 
604  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
605 
606  if (tty_write_string(PortFD, MFOC_cmd, &nbytes_written) == TTY_OK)
607  {
608 
609  int count = 0;
610  do
611  {
612  count ++;
613  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
614  MFOC_res[nbytes_read] = 0;
615  sscanf (MFOC_res, "%s %d", MFOC_res_type, &halt_flag);
616  } while(strcmp(MFOC_res_type, "H") != 0 && count <= 100);
617 
618  FocusAbsPosN[0].value = GetAbsFocuserPosition();
620  return true;
621  }
622  else
623  return false;
624 
625 }
626 
627 /************************************************************************************
628  *
629 ************************************************************************************/
631 {
632  LOGF_DEBUG("saveConfigItems()", 0);
633  // Save Focuser Config
635 
636  // Save additional MFPC Config
637  IUSaveConfigNumber(fp, &TempCompNP);
638  IUSaveConfigNumber(fp, &CurrentHoldingNP);
639  IUSaveConfigNumber(fp, &CurrentMovingNP);
640 
641  return true;
642 }
643 
644 uint32_t lacerta_mfoc_fmc::GetAbsFocuserPosition()
645 {
646  char MFOC_cmd[32] = ": q #";
647  char MFOC_res[32] = {0};
648  char MFOC_res_type[32] = "0";
649  int MFOC_pos_measd = 0;
650 
651  int nbytes_written = 0;
652  int nbytes_read = 0;
653  int count = 0;
654 
655  tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
656  LOGF_DEBUG("CMD [%s]", MFOC_cmd);
657 
658  do
659  {
660  tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);
661  sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_pos_measd);
662  count++;
663  }
664  while(strcmp(MFOC_res_type, "p") != 0 && count < 100);
665 
666  return static_cast<uint32_t>(MFOC_pos_measd);
667 }
668 
669 void lacerta_mfoc_fmc::IgnoreResponse()
670 {
671  int nbytes_read = 0;
672  char MFOC_res[64];
673  tty_read_section(PortFD, MFOC_res, 0xA, FOCUSMFOC_TIMEOUT, &nbytes_read);
674 }
675 
676 void lacerta_mfoc_fmc::IgnoreButLogResponse() {
677  int nbytes_read = 0;
678  char MFOC_res[64];
679  tty_read_section(PortFD, MFOC_res, 0xA, FOCUSMFOC_TIMEOUT, &nbytes_read);
680  MFOC_res[nbytes_read] = 0;
681  LOGF_DEBUG("*RES [%s]", MFOC_res);
682 }
683 
hid_device * device
bool isConnected() const
Definition: basedevice.cpp:520
const char * getDeviceName() const
Definition: basedevice.cpp:821
virtual bool loadConfig(bool silent=false, const char *property=nullptr)
Load the last saved configuration file.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
INumberVectorProperty FocusAbsPosNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition: indifocuser.cpp:95
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indifocuser.cpp:42
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
const char * getDefaultName() override
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
double max(void)
double min(void)
ISState
Switch state.
Definition: indiapi.h:150
@ ISS_OFF
Definition: indiapi.h:151
@ ISS_ON
Definition: indiapi.h:152
@ IP_RW
Definition: indiapi.h:186
@ IP_WO
Definition: indiapi.h:185
IPState
Property state.
Definition: indiapi.h:160
@ IPS_BUSY
Definition: indiapi.h:163
@ IPS_ALERT
Definition: indiapi.h:164
@ IPS_IDLE
Definition: indiapi.h:161
@ IPS_OK
Definition: indiapi.h:162
@ ISR_1OFMANY
Definition: indiapi.h:173
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition: indicom.c:566
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Definition: indicom.c:474
Implementations for common driver routines.
@ TTY_OK
Definition: indicom.h:150
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:272
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
Definition: indidevapi.c:128
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
Definition: indidevapi.c:15
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition: indidevapi.c:158
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
Definition: indidevapi.c:180
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:235
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
Definition: indidriver.c:1308
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
Definition: indidriver.c:1211
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
Definition: indidriver.c:1231
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
Definition: indidriver.c:1362
#define LOGF_INFO(fmt,...)
Definition: indilogger.h:82
#define LOGF_DEBUG(fmt,...)
Definition: indilogger.h:83
#define LOGF_ERROR(fmt,...)
Definition: indilogger.h:80
#define MFOC_POSMAX_HARDWARE
#define FOCUSMFOC_TIMEOUT
#define MFOC_POSMIN_HARDWARE
char name[MAXINDINAME]
Definition: indiapi.h:323
char name[MAXINDINAME]
Definition: indiapi.h:371