15 #include "modules/wltune.h"
23 static bool _initialized =
false;
24 static int _timeout = 0;
25 static int32_t _lastTune = -1;
27 WrxTuneInfo wlTuneInfo;
28 WlTuneState wlTuneState;
32 static const char * MODES[] = {
"not possible",
"eoptolink",
"OESolutions",
"simulated",
"lumentum",
"JDSU" };
34 void wltune_show_info()
36 logInfo(
"Tuning procedure is %s (%d), state=%d, to=%d", MODES[wlTuneInfo.tuneproc], wlTuneInfo.tuneproc, wlTuneState, _timeout);
37 if (wlTuneInfo.tuneproc == 0)
return;
38 logInfo(
"Tuning value: %d, Laser temperature: %lu", wlTuneInfo.tuneword, wlTuneInfo.laserTmpWl);
43 if (wltune_update_info()) {
45 if (wlTuneInfo.tuneproc == 0)
return true;
46 wlTuneState = WL_TUNE_STATE_IDLE;
48 wlTuneState = WL_TUNE_STATE_ERROR;
61 bool wltune_update_info()
69 bool wltune_set_word(int32_t t)
73 if (wlTuneState != WL_TUNE_STATE_IDLE && wlTuneState != WL_TUNE_STATE_ERROR)
76 _lastTune = wlTuneInfo.tuneword;
79 wlLastTuneNoAck =
false;
80 wlTuneState = WL_TUNE_STATE_BUSY;
84 wlTuneState = WL_TUNE_STATE_ERROR;
97 wlTuneState = WL_TUNE_STATE_IDLE;
105 bool wltune_periodic()
107 if (wlTuneState != WL_TUNE_STATE_IDLE && wlTuneState != WL_TUNE_STATE_ERROR)
logInfo(
"State=%d, To=%d\n", wlTuneState, _timeout);
108 if (_timeout > 0) _timeout--;
111 case WL_TUNE_STATE_BUSY:
112 wltune_update_info();
116 if (wlTuneInfo.laserTmpWl != 65535 && wlTuneInfo.laserTmpWl != 0)
119 uint16_t mint = wlTuneInfo.laserTmpWl > 256 ? wlTuneInfo.laserTmpWl - 256 : 0;
120 uint16_t maxt = wlTuneInfo.laserTmpWl < 65535-256 ? wlTuneInfo.laserTmpWl + 256 : 65535;
125 wrxSetSFPThreshold(WRX_SFP_LASER_TEMP_HIGH_ALARM, maxt);
126 wrxSetSFPThreshold(WRX_SFP_LASER_TEMP_HIGH_WARN, maxt);
127 wrxSetSFPThreshold(WRX_SFP_LASER_TEMP_LOW_ALARM, mint);
128 wrxSetSFPThreshold(WRX_SFP_LASER_TEMP_LOW_WARN, mint);
132 wlTuneState = WL_TUNE_STATE_WAITACK;
136 case WL_TUNE_STATE_WAITACK:
139 logError(
"No ack received, reverting DAC value");
141 wlTuneState = WL_TUNE_STATE_ERROR;
144 wlTuneState = WL_TUNE_STATE_BUSY;
146 wlLastTuneNoAck =
true;
bool wrxGetTuneInfo(WrxTuneInfo *info)
Sets the fields of the WrxTuneInfo structure.
#define E_INVSTATE
Generic error: Module is in a state in which.
Manages the global system error.
bool wrxSetTuneWord(int32_t tuneWord)
Sets the tune-word.
This module is responsible for distributing error codes.
#define logError(MSG,...)
Format a log message with fatal level.
#define LOG_DEF(NAME,...)
Define a logger for a module.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
#define ERROR(CODE,...)
Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).
Implements a generic logger facility.
#define logInfo(MSG,...)
Write a log message with formatting on info level.
#define E_NOTSUPPORTED
Generic error: not supported.