F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
LinuxSpiDriverComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxSpiDriverComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for LinuxSpiDriver component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Drv {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
21  init(FwEnumStoreType instance)
22  {
23  // Initialize base class
25 
26  // Connect input port SpiReadWrite
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_SpiReadWrite_InputPorts());
30  port++
31  ) {
32  this->m_SpiReadWrite_InputPort[port].init();
33  this->m_SpiReadWrite_InputPort[port].addCallComp(
34  this,
35  m_p_SpiReadWrite_in
36  );
37  this->m_SpiReadWrite_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_SpiReadWrite_InputPort[%" PRI_PlatformIntType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_SpiReadWrite_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect output port Log
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
54  port++
55  ) {
56  this->m_Log_OutputPort[port].init();
57 
58 #if FW_OBJECT_NAMES == 1
59  Fw::ObjectName portName;
60  portName.format(
61  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
62  this->m_objName.toChar(),
63  port
64  );
65  this->m_Log_OutputPort[port].setObjName(portName.toChar());
66 #endif
67  }
68 
69 #if FW_ENABLE_TEXT_LOGGING == 1
70  // Connect output port LogText
71  for (
72  FwIndexType port = 0;
73  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
74  port++
75  ) {
76  this->m_LogText_OutputPort[port].init();
77 
78 #if FW_OBJECT_NAMES == 1
79  Fw::ObjectName portName;
80  portName.format(
81  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
82  this->m_objName.toChar(),
83  port
84  );
85  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
86 #endif
87  }
88 #endif
89 
90  // Connect output port Time
91  for (
92  FwIndexType port = 0;
93  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
94  port++
95  ) {
96  this->m_Time_OutputPort[port].init();
97 
98 #if FW_OBJECT_NAMES == 1
99  Fw::ObjectName portName;
100  portName.format(
101  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
102  this->m_objName.toChar(),
103  port
104  );
105  this->m_Time_OutputPort[port].setObjName(portName.toChar());
106 #endif
107  }
108 
109  // Connect output port Tlm
110  for (
111  FwIndexType port = 0;
112  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
113  port++
114  ) {
115  this->m_Tlm_OutputPort[port].init();
116 
117 #if FW_OBJECT_NAMES == 1
118  Fw::ObjectName portName;
119  portName.format(
120  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
121  this->m_objName.toChar(),
122  port
123  );
124  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
125 #endif
126  }
127  }
128 
129  // ----------------------------------------------------------------------
130  // Getters for typed input ports
131  // ----------------------------------------------------------------------
132 
135  {
136  FW_ASSERT(
137  portNum < this->getNum_SpiReadWrite_InputPorts(),
138  static_cast<FwAssertArgType>(portNum)
139  );
140 
141  return &this->m_SpiReadWrite_InputPort[portNum];
142  }
143 
144  // ----------------------------------------------------------------------
145  // Connect input ports to special output ports
146  // ----------------------------------------------------------------------
147 
150  FwIndexType portNum,
151  Fw::InputLogPort* port
152  )
153  {
154  FW_ASSERT(
155  portNum < this->getNum_Log_OutputPorts(),
156  static_cast<FwAssertArgType>(portNum)
157  );
158 
159  this->m_Log_OutputPort[portNum].addCallPort(port);
160  }
161 
162 #if FW_ENABLE_TEXT_LOGGING == 1
163 
164  void LinuxSpiDriverComponentBase ::
165  set_LogText_OutputPort(
166  FwIndexType portNum,
168  )
169  {
170  FW_ASSERT(
171  portNum < this->getNum_LogText_OutputPorts(),
172  static_cast<FwAssertArgType>(portNum)
173  );
174 
175  this->m_LogText_OutputPort[portNum].addCallPort(port);
176  }
177 
178 #endif
179 
182  FwIndexType portNum,
183  Fw::InputTimePort* port
184  )
185  {
186  FW_ASSERT(
187  portNum < this->getNum_Time_OutputPorts(),
188  static_cast<FwAssertArgType>(portNum)
189  );
190 
191  this->m_Time_OutputPort[portNum].addCallPort(port);
192  }
193 
196  FwIndexType portNum,
197  Fw::InputTlmPort* port
198  )
199  {
200  FW_ASSERT(
201  portNum < this->getNum_Tlm_OutputPorts(),
202  static_cast<FwAssertArgType>(portNum)
203  );
204 
205  this->m_Tlm_OutputPort[portNum].addCallPort(port);
206  }
207 
208 #if FW_PORT_SERIALIZATION
209 
210  // ----------------------------------------------------------------------
211  // Connect serial input ports to special output ports
212  // ----------------------------------------------------------------------
213 
216  FwIndexType portNum,
217  Fw::InputSerializePort* port
218  )
219  {
220  FW_ASSERT(
221  portNum < this->getNum_Log_OutputPorts(),
222  static_cast<FwAssertArgType>(portNum)
223  );
224 
225  this->m_Log_OutputPort[portNum].registerSerialPort(port);
226  }
227 
228 #if FW_ENABLE_TEXT_LOGGING == 1
229 
230  void LinuxSpiDriverComponentBase ::
231  set_LogText_OutputPort(
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  )
235  {
236  FW_ASSERT(
237  portNum < this->getNum_LogText_OutputPorts(),
238  static_cast<FwAssertArgType>(portNum)
239  );
240 
241  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
242  }
243 
244 #endif
245 
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  )
251  {
252  FW_ASSERT(
253  portNum < this->getNum_Time_OutputPorts(),
254  static_cast<FwAssertArgType>(portNum)
255  );
256 
257  this->m_Time_OutputPort[portNum].registerSerialPort(port);
258  }
259 
262  FwIndexType portNum,
263  Fw::InputSerializePort* port
264  )
265  {
266  FW_ASSERT(
267  portNum < this->getNum_Tlm_OutputPorts(),
268  static_cast<FwAssertArgType>(portNum)
269  );
270 
271  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
272  }
273 
274 #endif
275 
276  // ----------------------------------------------------------------------
277  // Component construction and destruction
278  // ----------------------------------------------------------------------
279 
281  LinuxSpiDriverComponentBase(const char* compName) :
282  Fw::PassiveComponentBase(compName)
283  {
284  this->m_SPI_WriteErrorThrottle = 0;
285  }
286 
289  {
290 
291  }
292 
293  // ----------------------------------------------------------------------
294  // Getters for numbers of typed input ports
295  // ----------------------------------------------------------------------
296 
299  {
300  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_SpiReadWrite_InputPort));
301  }
302 
303  // ----------------------------------------------------------------------
304  // Getters for numbers of special output ports
305  // ----------------------------------------------------------------------
306 
309  {
310  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
311  }
312 
313 #if FW_ENABLE_TEXT_LOGGING == 1
314 
315  FwIndexType LinuxSpiDriverComponentBase ::
316  getNum_LogText_OutputPorts() const
317  {
318  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
319  }
320 
321 #endif
322 
325  {
326  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
327  }
328 
331  {
332  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
333  }
334 
335  // ----------------------------------------------------------------------
336  // Connection status queries for special output ports
337  // ----------------------------------------------------------------------
338 
341  {
342  FW_ASSERT(
343  portNum < this->getNum_Log_OutputPorts(),
344  static_cast<FwAssertArgType>(portNum)
345  );
346 
347  return this->m_Log_OutputPort[portNum].isConnected();
348  }
349 
350 #if FW_ENABLE_TEXT_LOGGING == 1
351 
352  bool LinuxSpiDriverComponentBase ::
353  isConnected_LogText_OutputPort(FwIndexType portNum)
354  {
355  FW_ASSERT(
356  portNum < this->getNum_LogText_OutputPorts(),
357  static_cast<FwAssertArgType>(portNum)
358  );
359 
360  return this->m_LogText_OutputPort[portNum].isConnected();
361  }
362 
363 #endif
364 
367  {
368  FW_ASSERT(
369  portNum < this->getNum_Time_OutputPorts(),
370  static_cast<FwAssertArgType>(portNum)
371  );
372 
373  return this->m_Time_OutputPort[portNum].isConnected();
374  }
375 
378  {
379  FW_ASSERT(
380  portNum < this->getNum_Tlm_OutputPorts(),
381  static_cast<FwAssertArgType>(portNum)
382  );
383 
384  return this->m_Tlm_OutputPort[portNum].isConnected();
385  }
386 
387  // ----------------------------------------------------------------------
388  // Port handler base-class functions for typed input ports
389  //
390  // Call these functions directly to bypass the corresponding ports
391  // ----------------------------------------------------------------------
392 
395  FwIndexType portNum,
396  Fw::Buffer& writeBuffer,
397  Fw::Buffer& readBuffer
398  )
399  {
400  // Make sure port number is valid
401  FW_ASSERT(
402  portNum < this->getNum_SpiReadWrite_InputPorts(),
403  static_cast<FwAssertArgType>(portNum)
404  );
405 
406  // Call handler function
407  this->SpiReadWrite_handler(
408  portNum,
409  writeBuffer,
410  readBuffer
411  );
412  }
413 
414  // ----------------------------------------------------------------------
415  // Event logging functions
416  // ----------------------------------------------------------------------
417 
420  I32 device,
421  I32 select,
422  I32 error
423  )
424  {
425  // Get the time
426  Fw::Time _logTime;
427  if (this->m_Time_OutputPort[0].isConnected()) {
428  this->m_Time_OutputPort[0].invoke(_logTime);
429  }
430 
431  FwEventIdType _id = static_cast<FwEventIdType>(0);
432 
433  _id = this->getIdBase() + EVENTID_SPI_OPENERROR;
434 
435  // Emit the event on the log port
436  if (this->m_Log_OutputPort[0].isConnected()) {
437  Fw::LogBuffer _logBuff;
439 
440 #if FW_AMPCS_COMPATIBLE
441  // Serialize the number of arguments
442  _status = _logBuff.serialize(static_cast<U8>(3));
443  FW_ASSERT(
444  _status == Fw::FW_SERIALIZE_OK,
445  static_cast<FwAssertArgType>(_status)
446  );
447 #endif
448 
449 #if FW_AMPCS_COMPATIBLE
450  // Serialize the argument size
451  _status = _logBuff.serialize(
452  static_cast<U8>(sizeof(I32))
453  );
454  FW_ASSERT(
455  _status == Fw::FW_SERIALIZE_OK,
456  static_cast<FwAssertArgType>(_status)
457  );
458 #endif
459  _status = _logBuff.serialize(device);
460  FW_ASSERT(
461  _status == Fw::FW_SERIALIZE_OK,
462  static_cast<FwAssertArgType>(_status)
463  );
464 
465 #if FW_AMPCS_COMPATIBLE
466  // Serialize the argument size
467  _status = _logBuff.serialize(
468  static_cast<U8>(sizeof(I32))
469  );
470  FW_ASSERT(
471  _status == Fw::FW_SERIALIZE_OK,
472  static_cast<FwAssertArgType>(_status)
473  );
474 #endif
475  _status = _logBuff.serialize(select);
476  FW_ASSERT(
477  _status == Fw::FW_SERIALIZE_OK,
478  static_cast<FwAssertArgType>(_status)
479  );
480 
481 #if FW_AMPCS_COMPATIBLE
482  // Serialize the argument size
483  _status = _logBuff.serialize(
484  static_cast<U8>(sizeof(I32))
485  );
486  FW_ASSERT(
487  _status == Fw::FW_SERIALIZE_OK,
488  static_cast<FwAssertArgType>(_status)
489  );
490 #endif
491  _status = _logBuff.serialize(error);
492  FW_ASSERT(
493  _status == Fw::FW_SERIALIZE_OK,
494  static_cast<FwAssertArgType>(_status)
495  );
496 
497  this->m_Log_OutputPort[0].invoke(
498  _id,
499  _logTime,
501  _logBuff
502  );
503  }
504 
505  // Emit the event on the text log port
506 #if FW_ENABLE_TEXT_LOGGING
507  if (this->m_LogText_OutputPort[0].isConnected()) {
508 #if FW_OBJECT_NAMES == 1
509  const char* _formatString =
510  "(%s) %s: Error opening SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
511 #else
512  const char* _formatString =
513  "%s: Error opening SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
514 #endif
515 
516  Fw::TextLogString _logString;
517  _logString.format(
518  _formatString,
519 #if FW_OBJECT_NAMES == 1
520  this->m_objName.toChar(),
521 #endif
522  "SPI_OpenError ",
523  device,
524  select,
525  error
526  );
527 
528  this->m_LogText_OutputPort[0].invoke(
529  _id,
530  _logTime,
532  _logString
533  );
534  }
535 #endif
536  }
537 
540  I32 device,
541  I32 select,
542  I32 error
543  )
544  {
545  // Get the time
546  Fw::Time _logTime;
547  if (this->m_Time_OutputPort[0].isConnected()) {
548  this->m_Time_OutputPort[0].invoke(_logTime);
549  }
550 
551  FwEventIdType _id = static_cast<FwEventIdType>(0);
552 
553  _id = this->getIdBase() + EVENTID_SPI_CONFIGERROR;
554 
555  // Emit the event on the log port
556  if (this->m_Log_OutputPort[0].isConnected()) {
557  Fw::LogBuffer _logBuff;
559 
560 #if FW_AMPCS_COMPATIBLE
561  // Serialize the number of arguments
562  _status = _logBuff.serialize(static_cast<U8>(3));
563  FW_ASSERT(
564  _status == Fw::FW_SERIALIZE_OK,
565  static_cast<FwAssertArgType>(_status)
566  );
567 #endif
568 
569 #if FW_AMPCS_COMPATIBLE
570  // Serialize the argument size
571  _status = _logBuff.serialize(
572  static_cast<U8>(sizeof(I32))
573  );
574  FW_ASSERT(
575  _status == Fw::FW_SERIALIZE_OK,
576  static_cast<FwAssertArgType>(_status)
577  );
578 #endif
579  _status = _logBuff.serialize(device);
580  FW_ASSERT(
581  _status == Fw::FW_SERIALIZE_OK,
582  static_cast<FwAssertArgType>(_status)
583  );
584 
585 #if FW_AMPCS_COMPATIBLE
586  // Serialize the argument size
587  _status = _logBuff.serialize(
588  static_cast<U8>(sizeof(I32))
589  );
590  FW_ASSERT(
591  _status == Fw::FW_SERIALIZE_OK,
592  static_cast<FwAssertArgType>(_status)
593  );
594 #endif
595  _status = _logBuff.serialize(select);
596  FW_ASSERT(
597  _status == Fw::FW_SERIALIZE_OK,
598  static_cast<FwAssertArgType>(_status)
599  );
600 
601 #if FW_AMPCS_COMPATIBLE
602  // Serialize the argument size
603  _status = _logBuff.serialize(
604  static_cast<U8>(sizeof(I32))
605  );
606  FW_ASSERT(
607  _status == Fw::FW_SERIALIZE_OK,
608  static_cast<FwAssertArgType>(_status)
609  );
610 #endif
611  _status = _logBuff.serialize(error);
612  FW_ASSERT(
613  _status == Fw::FW_SERIALIZE_OK,
614  static_cast<FwAssertArgType>(_status)
615  );
616 
617  this->m_Log_OutputPort[0].invoke(
618  _id,
619  _logTime,
621  _logBuff
622  );
623  }
624 
625  // Emit the event on the text log port
626 #if FW_ENABLE_TEXT_LOGGING
627  if (this->m_LogText_OutputPort[0].isConnected()) {
628 #if FW_OBJECT_NAMES == 1
629  const char* _formatString =
630  "(%s) %s: Error configuring SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
631 #else
632  const char* _formatString =
633  "%s: Error configuring SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
634 #endif
635 
636  Fw::TextLogString _logString;
637  _logString.format(
638  _formatString,
639 #if FW_OBJECT_NAMES == 1
640  this->m_objName.toChar(),
641 #endif
642  "SPI_ConfigError ",
643  device,
644  select,
645  error
646  );
647 
648  this->m_LogText_OutputPort[0].invoke(
649  _id,
650  _logTime,
652  _logString
653  );
654  }
655 #endif
656  }
657 
660  I32 device,
661  I32 select,
662  I32 error
663  )
664  {
665  // Check throttle value
666  if (this->m_SPI_WriteErrorThrottle >= EVENTID_SPI_WRITEERROR_THROTTLE) {
667  return;
668  }
669  else {
670  this->m_SPI_WriteErrorThrottle++;
671  }
672 
673  // Get the time
674  Fw::Time _logTime;
675  if (this->m_Time_OutputPort[0].isConnected()) {
676  this->m_Time_OutputPort[0].invoke(_logTime);
677  }
678 
679  FwEventIdType _id = static_cast<FwEventIdType>(0);
680 
681  _id = this->getIdBase() + EVENTID_SPI_WRITEERROR;
682 
683  // Emit the event on the log port
684  if (this->m_Log_OutputPort[0].isConnected()) {
685  Fw::LogBuffer _logBuff;
687 
688 #if FW_AMPCS_COMPATIBLE
689  // Serialize the number of arguments
690  _status = _logBuff.serialize(static_cast<U8>(3));
691  FW_ASSERT(
692  _status == Fw::FW_SERIALIZE_OK,
693  static_cast<FwAssertArgType>(_status)
694  );
695 #endif
696 
697 #if FW_AMPCS_COMPATIBLE
698  // Serialize the argument size
699  _status = _logBuff.serialize(
700  static_cast<U8>(sizeof(I32))
701  );
702  FW_ASSERT(
703  _status == Fw::FW_SERIALIZE_OK,
704  static_cast<FwAssertArgType>(_status)
705  );
706 #endif
707  _status = _logBuff.serialize(device);
708  FW_ASSERT(
709  _status == Fw::FW_SERIALIZE_OK,
710  static_cast<FwAssertArgType>(_status)
711  );
712 
713 #if FW_AMPCS_COMPATIBLE
714  // Serialize the argument size
715  _status = _logBuff.serialize(
716  static_cast<U8>(sizeof(I32))
717  );
718  FW_ASSERT(
719  _status == Fw::FW_SERIALIZE_OK,
720  static_cast<FwAssertArgType>(_status)
721  );
722 #endif
723  _status = _logBuff.serialize(select);
724  FW_ASSERT(
725  _status == Fw::FW_SERIALIZE_OK,
726  static_cast<FwAssertArgType>(_status)
727  );
728 
729 #if FW_AMPCS_COMPATIBLE
730  // Serialize the argument size
731  _status = _logBuff.serialize(
732  static_cast<U8>(sizeof(I32))
733  );
734  FW_ASSERT(
735  _status == Fw::FW_SERIALIZE_OK,
736  static_cast<FwAssertArgType>(_status)
737  );
738 #endif
739  _status = _logBuff.serialize(error);
740  FW_ASSERT(
741  _status == Fw::FW_SERIALIZE_OK,
742  static_cast<FwAssertArgType>(_status)
743  );
744 
745  this->m_Log_OutputPort[0].invoke(
746  _id,
747  _logTime,
749  _logBuff
750  );
751  }
752 
753  // Emit the event on the text log port
754 #if FW_ENABLE_TEXT_LOGGING
755  if (this->m_LogText_OutputPort[0].isConnected()) {
756 #if FW_OBJECT_NAMES == 1
757  const char* _formatString =
758  "(%s) %s: Error writing/reading SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
759 #else
760  const char* _formatString =
761  "%s: Error writing/reading SPI device %" PRIi32 ".%" PRIi32 ": %" PRIi32 "";
762 #endif
763 
764  Fw::TextLogString _logString;
765  _logString.format(
766  _formatString,
767 #if FW_OBJECT_NAMES == 1
768  this->m_objName.toChar(),
769 #endif
770  "SPI_WriteError ",
771  device,
772  select,
773  error
774  );
775 
776  this->m_LogText_OutputPort[0].invoke(
777  _id,
778  _logTime,
780  _logString
781  );
782  }
783 #endif
784  }
785 
788  I32 device,
789  I32 select
790  )
791  {
792  // Get the time
793  Fw::Time _logTime;
794  if (this->m_Time_OutputPort[0].isConnected()) {
795  this->m_Time_OutputPort[0].invoke(_logTime);
796  }
797 
798  FwEventIdType _id = static_cast<FwEventIdType>(0);
799 
800  _id = this->getIdBase() + EVENTID_SPI_PORTOPENED;
801 
802  // Emit the event on the log port
803  if (this->m_Log_OutputPort[0].isConnected()) {
804  Fw::LogBuffer _logBuff;
806 
807 #if FW_AMPCS_COMPATIBLE
808  // Serialize the number of arguments
809  _status = _logBuff.serialize(static_cast<U8>(2));
810  FW_ASSERT(
811  _status == Fw::FW_SERIALIZE_OK,
812  static_cast<FwAssertArgType>(_status)
813  );
814 #endif
815 
816 #if FW_AMPCS_COMPATIBLE
817  // Serialize the argument size
818  _status = _logBuff.serialize(
819  static_cast<U8>(sizeof(I32))
820  );
821  FW_ASSERT(
822  _status == Fw::FW_SERIALIZE_OK,
823  static_cast<FwAssertArgType>(_status)
824  );
825 #endif
826  _status = _logBuff.serialize(device);
827  FW_ASSERT(
828  _status == Fw::FW_SERIALIZE_OK,
829  static_cast<FwAssertArgType>(_status)
830  );
831 
832 #if FW_AMPCS_COMPATIBLE
833  // Serialize the argument size
834  _status = _logBuff.serialize(
835  static_cast<U8>(sizeof(I32))
836  );
837  FW_ASSERT(
838  _status == Fw::FW_SERIALIZE_OK,
839  static_cast<FwAssertArgType>(_status)
840  );
841 #endif
842  _status = _logBuff.serialize(select);
843  FW_ASSERT(
844  _status == Fw::FW_SERIALIZE_OK,
845  static_cast<FwAssertArgType>(_status)
846  );
847 
848  this->m_Log_OutputPort[0].invoke(
849  _id,
850  _logTime,
852  _logBuff
853  );
854  }
855 
856  // Emit the event on the text log port
857 #if FW_ENABLE_TEXT_LOGGING
858  if (this->m_LogText_OutputPort[0].isConnected()) {
859 #if FW_OBJECT_NAMES == 1
860  const char* _formatString =
861  "(%s) %s: SPI Device %" PRIi32 ".%" PRIi32 " configured";
862 #else
863  const char* _formatString =
864  "%s: SPI Device %" PRIi32 ".%" PRIi32 " configured";
865 #endif
866 
867  Fw::TextLogString _logString;
868  _logString.format(
869  _formatString,
870 #if FW_OBJECT_NAMES == 1
871  this->m_objName.toChar(),
872 #endif
873  "SPI_PortOpened ",
874  device,
875  select
876  );
877 
878  this->m_LogText_OutputPort[0].invoke(
879  _id,
880  _logTime,
882  _logString
883  );
884  }
885 #endif
886  }
887 
888  // ----------------------------------------------------------------------
889  // Event throttle reset functions
890  // ----------------------------------------------------------------------
891 
894  {
895  // Reset throttle counter
896  this->m_SPI_WriteErrorThrottle = 0;
897  }
898 
899  // ----------------------------------------------------------------------
900  // Telemetry write functions
901  // ----------------------------------------------------------------------
902 
905  U32 arg,
906  Fw::Time _tlmTime
907  )
908  {
909  if (this->m_Tlm_OutputPort[0].isConnected()) {
910  if (
911  this->m_Time_OutputPort[0].isConnected() &&
912  (_tlmTime == Fw::ZERO_TIME)
913  ) {
914  this->m_Time_OutputPort[0].invoke(_tlmTime);
915  }
916 
917  Fw::TlmBuffer _tlmBuff;
918  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
919  FW_ASSERT(
920  _stat == Fw::FW_SERIALIZE_OK,
921  static_cast<FwAssertArgType>(_stat)
922  );
923 
924  FwChanIdType _id;
925 
926  _id = this->getIdBase() + CHANNELID_SPI_BYTES;
927 
928  this->m_Tlm_OutputPort[0].invoke(
929  _id,
930  _tlmTime,
931  _tlmBuff
932  );
933  }
934  }
935 
936  // ----------------------------------------------------------------------
937  // Time
938  // ----------------------------------------------------------------------
939 
941  getTime()
942  {
943  if (this->m_Time_OutputPort[0].isConnected()) {
944  Fw::Time _time;
945  this->m_Time_OutputPort[0].invoke(_time);
946  return _time;
947  }
948  else {
949  return Fw::Time(TB_NONE, 0, 0);
950  }
951  }
952 
953  // ----------------------------------------------------------------------
954  // Calls for messages received on typed input ports
955  // ----------------------------------------------------------------------
956 
957  void LinuxSpiDriverComponentBase ::
958  m_p_SpiReadWrite_in(
959  Fw::PassiveComponentBase* callComp,
960  FwIndexType portNum,
961  Fw::Buffer& writeBuffer,
962  Fw::Buffer& readBuffer
963  )
964  {
965  FW_ASSERT(callComp);
966  LinuxSpiDriverComponentBase* compPtr = static_cast<LinuxSpiDriverComponentBase*>(callComp);
967  compPtr->SpiReadWrite_handlerBase(
968  portNum,
969  writeBuffer,
970  readBuffer
971  );
972  }
973 
974 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:70
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:70
I32 FwEnumStoreType
Definition: FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
U32 FwChanIdType
Definition: FpConfig.h:95
U32 FwEventIdType
Definition: FpConfig.h:103
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:148
Input SpiReadWrite port.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
Auto-generated base for LinuxSpiDriver component.
void log_WARNING_HI_SPI_WriteError(I32 device, I32 select, I32 error)
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
LinuxSpiDriverComponentBase(const char *compName="")
Construct LinuxSpiDriverComponentBase object.
void tlmWrite_SPI_Bytes(U32 arg, Fw::Time _tlmTime=Fw::Time())
@ EVENTID_SPI_WRITEERROR_THROTTLE
Throttle reset count for SPI_WriteError.
void log_WARNING_HI_SPI_WriteError_ThrottleClear()
Reset throttle value for SPI_WriteError.
Drv::InputSpiReadWritePort * get_SpiReadWrite_InputPort(FwIndexType portNum)
void log_WARNING_HI_SPI_ConfigError(I32 device, I32 select, I32 error)
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_SPI_PortOpened(I32 device, I32 select)
@ CHANNELID_SPI_BYTES
Channel ID for SPI_Bytes.
bool isConnected_Log_OutputPort(FwIndexType portNum)
bool isConnected_Time_OutputPort(FwIndexType portNum)
virtual ~LinuxSpiDriverComponentBase()
Destroy LinuxSpiDriverComponentBase object.
virtual void SpiReadWrite_handler(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)=0
Handler for input port SpiReadWrite.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
void SpiReadWrite_handlerBase(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)
Handler base-class function for input port SpiReadWrite.
void log_WARNING_HI_SPI_OpenError(I32 device, I32 select, I32 error)
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected()
Definition: PortBase.cpp:41
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
Definition: Time.hpp:9
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5