Cat
Public Member Functions | Protected Attributes | Private Attributes | List of all members
SpecsInterface Class Reference

#include <include/SpecsInterface.h>

Inheritance diagram for SpecsInterface:
Interface Element Hierarchy Object Attrib SpecsBus SpecsI2c SpecsParallelBus SpecsSlave SpecsGlue SpecsMezzanine

Public Member Functions

 SpecsInterface ()
 
virtual ~SpecsInterface ()
 
virtual void help ()
 
virtual StatusCode init ()
 
virtual void reset ()
 
virtual void update ()
 
void setAddress (unsigned char)
 
unsigned char address ()
 
void setOutputSelect (unsigned char)
 
unsigned char outputSelect ()
 
virtual SpecsSlavespecsSlave ()
 
virtual SpecsMasterspecsMaster ()
 
virtual SPECSSLAVE * specsSlaveDevice ()
 
virtual SPECSMASTER * specsMasterDevice ()
 
virtual StatusCode read (IOdata *io)
 
virtual StatusCode write (IOdata *io)
 
bool specsWriteI2c (unsigned char address, unsigned char nData, U8 *data)
 
bool specsWriteI2c (unsigned char address, std::vector< U8 > data)
 
bool specsReadI2c (unsigned char address, unsigned char nOctects, U8 *i2cWords)
 
bool specsReadI2c (unsigned char address, std::vector< unsigned char > &specsWords)
 
bool specsWriteI2c (unsigned char address, unsigned char subAddress, unsigned char nData, U8 *data)
 
bool specsWriteI2c (unsigned char address, unsigned char outputSel, unsigned char subAddress, unsigned char nData, U8 *data)
 
bool specsReadI2c (unsigned char address, unsigned char subAddress, unsigned char nOctets, U8 *i2cWords)
 
bool specsReadI2c (unsigned char address, unsigned char outputSel, unsigned char subAddress, unsigned char nOctets, U8 *i2cWords)
 
bool specsWriteParallel (unsigned char address, unsigned short data)
 
bool specsReadParallel (unsigned char address, U16 &data)
 
bool specsWriteRegister (unsigned char, unsigned short)
 
bool specsReadRegister (unsigned char, U16 &)
 
- Public Member Functions inherited from Interface
 Interface ()
 Standard constructor. More...
 
virtual ~Interface ()
 Destructor. More...
 
- Public Member Functions inherited from Element
 Element ()
 Standard constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
void recursiveInitElement ()
 
void recursiveInitCommunications ()
 
StatusCode setConnection (Hierarchy *)
 
Hierarchyconnection ()
 
- Public Member Functions inherited from Hierarchy
 Hierarchy ()
 Standard constructor. More...
 
virtual ~Hierarchy ()
 Destructor. More...
 
void clear ()
 
void setParent (Hierarchy *parent)
 
Hierarchyparent ()
 
Hierarchyparent (std::string)
 
Hierarchyorigin ()
 
virtual void addChild (Hierarchy *element)
 
std::vector< Hierarchy * > children ()
 
Hierarchychild (std::string)
 
HierarchychildTyped (std::string)
 
unsigned long numberOfChildren ()
 
bool hasChildren ()
 
void delChild (Hierarchy *)
 
void delChild (std::string)
 
std::string path (std::string=std::string(""))
 
std::string pathTyped (std::string=std::string(""))
 
void tree (std::string indent=std::string(""))
 
void tree ()
 
- Public Member Functions inherited from Object
 Object ()
 Standard constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string name () const
 
std::string type ()
 
unsigned char id ()
 
std::string title ()
 
void msgSvc (int level, std::string msg, std::string name)
 
void msg (std::string mymsg)
 
void verbose (std::string mymsg)
 
void debug (std::string mymsg)
 
void info (std::string mymsg)
 
void warning (std::string mymsg)
 
void error (std::string mymsg)
 
void fatal (std::string mymsg)
 
void msg (std::string mymsg, std::string name)
 
void verbose (std::string mymsg, std::string name)
 
void debug (std::string mymsg, std::string name)
 
void info (std::string mymsg, std::string name)
 
void warning (std::string mymsg, std::string name)
 
void error (std::string mymsg, std::string name)
 
void fatal (std::string mymsg, std::string name)
 
void setName (std::string name)
 
void setType (std::string type)
 
void setId (unsigned char id)
 
void setTitle (std::string title)
 
void setDllName (std::string dllName)
 
std::string dllName ()
 
- Public Member Functions inherited from Attrib
 Attrib ()
 Standard constructor. More...
 
virtual ~Attrib ()
 Destructor. More...
 
bool is (int attribut)
 
void add (int attribut)
 
void remove (int attribut)
 
std::string attributs ()
 

Protected Attributes

unsigned char m_address
 
unsigned char m_outputSelect
 
- Protected Attributes inherited from Element
Hierarchym_connection
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Private Attributes

int m_slot
 

Additional Inherited Members

- Public Types inherited from Attrib
enum  Attribut {
  UNDEFINED, PASSIVE, ACTIVE, INTERFACE,
  IO, IODATA, ELEMENT, HARDWARE,
  PROCESSUS, SOFTWARE
}
 

Detailed Description

Class to describe general electronics object

Author
Frederic Machefert
Date
2004-01-18

Definition at line 54 of file SpecsInterface.h.

Constructor & Destructor Documentation

◆ SpecsInterface()

SpecsInterface::SpecsInterface ( )

Definition at line 21 of file SpecsInterface.cpp.

References m_address, m_outputSelect, and Object::setId().

21  {
22  m_address=0;
23  m_outputSelect=0x0;
24  setId(0);
25 
26 
27 }
void setId(unsigned char id)
Definition: Object.h:53
unsigned char m_address
unsigned char m_outputSelect

◆ ~SpecsInterface()

virtual SpecsInterface::~SpecsInterface ( )
inlinevirtual

Definition at line 57 of file SpecsInterface.h.

57 {} //< Destructor

Member Function Documentation

◆ address()

unsigned char SpecsInterface::address ( )

◆ help()

virtual void SpecsInterface::help ( )
inlinevirtual

printout help for the element

Implements Interface.

Reimplemented in SpecsParallelBus, SpecsMezzanine, and SpecsGlue.

Definition at line 63 of file SpecsInterface.h.

Referenced by BOOST_PYTHON_MODULE().

63 { info("SpecsInterface "+name()+". No help.","SpecsInterface::help"); };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ init()

virtual StatusCode SpecsInterface::init ( )
inlinevirtual

init the component

Returns
void

Implements Interface.

Reimplemented in SpecsSlave, and SpecsParallelBus.

Definition at line 69 of file SpecsInterface.h.

References StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

69  {
70  info("SpecsInterface "+name()+" initialization.","SpecsInterface::init");
71  return StatusCode::SUCCESS;
72  };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ outputSelect()

unsigned char SpecsInterface::outputSelect ( )

Definition at line 41 of file SpecsInterface.cpp.

References m_outputSelect.

Referenced by BOOST_PYTHON_MODULE(), setOutputSelect(), specsReadI2c(), and specsWriteI2c().

41  {
42  return m_outputSelect;
43 }
unsigned char m_outputSelect

◆ read()

virtual StatusCode SpecsInterface::read ( IOdata io)
inlinevirtual

Implements Interface.

Definition at line 124 of file SpecsInterface.h.

References StatusCode::SUCCESS.

◆ reset()

virtual void SpecsInterface::reset ( )
inlinevirtual

Resets the Element so that is is in a standard and safe situation. Different from Element::init which configure the Element. Element::reset() is more an Emergency pull. It is often/usually called by the recursiveInitElement method at the start of the program.

Implements Interface.

Reimplemented in SpecsSlave, and SpecsParallelBus.

Definition at line 81 of file SpecsInterface.h.

Referenced by BOOST_PYTHON_MODULE().

81 { info("SpecsInterface "+name()+" reset.","SpecsInterface::reset");};
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ setAddress()

void SpecsInterface::setAddress ( unsigned char  address)

Definition at line 29 of file SpecsInterface.cpp.

References address(), and m_address.

Referenced by BOOST_PYTHON_MODULE().

29  {
31 }
unsigned char address()
unsigned char m_address

◆ setOutputSelect()

void SpecsInterface::setOutputSelect ( unsigned char  outputSelect)

Definition at line 37 of file SpecsInterface.cpp.

References m_outputSelect, and outputSelect().

Referenced by BOOST_PYTHON_MODULE().

37  {
39 }
unsigned char m_outputSelect
unsigned char outputSelect()

◆ specsMaster()

SpecsMaster * SpecsInterface::specsMaster ( )
virtual

Get the closest master in the element hierarchy

Returns
SpecsMaster

Definition at line 57 of file SpecsInterface.cpp.

References Hierarchy::parent(), and specsMaster().

Referenced by BOOST_PYTHON_MODULE(), SpecsSlave::detect(), and specsMaster().

57  {
58  if (0!=parent()){
59  SpecsInterface* tmp = dynamic_cast <SpecsInterface*> (parent());
60  if ( 0 != tmp ) return tmp->specsMaster();
61  }
62  return (SpecsMaster*)NULL;
63 }
virtual SpecsMaster * specsMaster()
Hierarchy * parent()
Definition: Hierarchy.h:28

◆ specsMasterDevice()

SPECSMASTER * SpecsInterface::specsMasterDevice ( )
virtual

Get the closest master in the element hierarchy

Returns
SPECSMASTER*

Definition at line 76 of file SpecsInterface.cpp.

References Hierarchy::parent(), and specsMasterDevice().

Referenced by SpecsSlave::detect(), SpecsSlave::init(), and specsMasterDevice().

76  {
77  if (0!=parent()){
78  SpecsInterface* tmp = dynamic_cast <SpecsInterface*> (parent());
79  if ( 0 != tmp ) return tmp->specsMasterDevice();
80  }
81  return (SPECSMASTER*)NULL;
82 }
Hierarchy * parent()
Definition: Hierarchy.h:28
virtual SPECSMASTER * specsMasterDevice()

◆ specsReadI2c() [1/4]

bool SpecsInterface::specsReadI2c ( unsigned char  address,
unsigned char  nOctects,
U8 i2cWords 
)

Read nOctets from i2c slave address. specsWords contains nSpecsWords containing the i2c data.

Returns
bool
Parameters
[in]addressi2c Slave address
[in]nOctectnumber of octets to read
[in]nSpecsWordsnumber of specs words to retrieve
[out]specsWordscontains the specs words with the i2c data

Definition at line 191 of file SpecsInterface.cpp.

References itos(), outputSelect(), specsSlaveDevice(), Object::verbose(), and Object::warning().

Referenced by SpecsMezzanine::cmdline(), and specsReadI2c().

193  {
194 #ifndef _NODEVICE_
195  SPECSSLAVE *specsSlv=specsSlaveDevice();
196  if ( 0==specsSlv ){
197  warning("Could not reach proper Specs Master and/or Slave.",
198  "SpecsInterface::specsReadI2c");
199  return false;
200  }
201  SpecsError status = specs_i2c_read ( specsSlv, outputSelect() , i2cAdd , nOctets , i2cWords );
202  if (0!=status){
203  warning("failure at address " + itos (i2cAdd) + "[code=" + itos(status) + "]",
204  "specsReadI2c" );
205  // specsMaster() -> reset();
206  }
207  else {
208  verbose(itos(nOctets) + " words read at address " + itos(i2cAdd),"SpecsReadI2c");
209  }
210 #else
211  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsReadI2c");
212 #endif
213  return true;
214 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
virtual SPECSSLAVE * specsSlaveDevice()
unsigned char outputSelect()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsReadI2c() [2/4]

bool SpecsInterface::specsReadI2c ( unsigned char  address,
std::vector< unsigned char > &  specsWords 
)

Read a vector of given size from i2c slave address.

Returns
bool (false if vector of size 0 or reading error)
Parameters
[in]addressi2c Slave address
[out]specsWordscontains the specs words with the i2c data

Definition at line 216 of file SpecsInterface.cpp.

References specsReadI2c(), and Object::warning().

217  {
218 
219  int nOctets = specsWords.size();
220  if( nOctets==0) {
221  warning("The vector of data to read should have a non-zero size",
222  "SpecsInterface::specsReadI2c");
223  return false;
224  }
225 
226  U8 BufferSource[50];
227 
228  bool status = specsReadI2c(address, nOctets, BufferSource);
229 
230  for(int j=0; j<nOctets; ++j) specsWords[j] = static_cast<unsigned char>(BufferSource[j]);
231 
232  return status;
233 }
bool specsReadI2c(unsigned char address, unsigned char nOctects, U8 *i2cWords)
unsigned char address()
unsigned char U8
Definition: ICECALv3.h:55
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsReadI2c() [3/4]

bool SpecsInterface::specsReadI2c ( unsigned char  address,
unsigned char  subAddress,
unsigned char  nOctets,
U8 i2cWords 
)

Read nOctets from i2c slave address at subAddress. specsWords contains nSpecsWords containing the i2c data.

Returns
bool
Parameters
[in]addressi2c Slave address
[in]nOctectnumber of octets to read
[in]nSpecsWordsnumber of specs words to retrieve
[out]specsWordscontains the specs words with the i2c data

Definition at line 235 of file SpecsInterface.cpp.

References itos(), outputSelect(), specsSlaveDevice(), Object::verbose(), and Object::warning().

238  {
239 #ifndef _NODEVICE_
240  SPECSSLAVE *specsSlv=specsSlaveDevice();
241  if ( 0==specsSlv ){
242  warning("Could not reach proper Specs Master and/or Slave.","SpecsInterface::specsReadI2c");
243  return false;
244  }
245  SpecsError status = specs_i2c_read_sub ( specsSlv, outputSelect() , i2cAdd , subAdd , nOctets , i2cWords );
246  if (0!=status){
247  warning("failure at address " + itos (i2cAdd) + "/ subAddress " + itos(subAdd) +
248  " [code=" + itos(status) + "]" ,
249  "specsReadI2c");
250  // specsMaster() -> reset();
251  }
252  else {
253  verbose(itos(nOctets) + " words read at address " + itos(i2cAdd) +
254  "/ subAddress " + itos(subAdd),
255  "SpecsReadI2c");
256  }
257 #else
258  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsReadI2c");
259 #endif
260  return true;
261 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
virtual SPECSSLAVE * specsSlaveDevice()
unsigned char outputSelect()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsReadI2c() [4/4]

bool SpecsInterface::specsReadI2c ( unsigned char  address,
unsigned char  outputSel,
unsigned char  subAddress,
unsigned char  nOctets,
U8 i2cWords 
)

Read nOctets from i2c slave address at subAddress. specsWords contains nSpecsWords containing the i2c data.

Returns
bool
Parameters
[in]addressi2c Slave address
[in]outputSeli2c Slave output select
[in]nOctectnumber of octets to read
[in]nSpecsWordsnumber of specs words to retrieve
[out]specsWordscontains the specs words with the i2c data

Definition at line 263 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

267  {
268 #ifndef _NODEVICE_
269  SPECSSLAVE *specsSlv=specsSlaveDevice();
270  if ( 0==specsSlv ){
271  warning("Could not reach proper Specs Master and/or Slave.",
272  "SpecsInterface::specsReadI2c");
273  return false;
274  }
275  SpecsError status = specs_i2c_read_sub ( specsSlv, outputSel ,
276  i2cAdd , subAdd ,
277  nOctets , i2cWords );
278  if (0!=status){
279  warning("failure at address " + itos (i2cAdd) + "/ subAddress " + itos(subAdd) +
280  " [code=" + itos(status) + "]",
281  "specsReadI2c" );
282  // specsMaster() -> reset();
283  }
284  else {
285  verbose(itos(nOctets) + " words read at address " + itos(i2cAdd) +
286  "/ subAddress " + itos(subAdd),
287  "SpecsReadI2c");
288  }
289 #else
290  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsReadI2c");
291 #endif
292  return true;
293 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsReadParallel()

bool SpecsInterface::specsReadParallel ( unsigned char  address,
U16 data 
)

Read data at address on parallel bus

Returns
bool
Parameters
[in]addressaddress bus
[in]datadata bus

Definition at line 323 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

324  {
325 #ifndef _NODEVICE_
326  SPECSSLAVE *specsSlv=specsSlaveDevice();
327  if ( 0==specsSlv ){
328  warning("Could not reach proper SpecsSlave/Master.","SpecsInterface::specsReadI2c");
329  return false;
330  }
331  SpecsError status = specs_parallel_read( specsSlv , add , 1 , &parallelBus );
332  if (0!=status){
333  warning("failure at address " + itos (add) +
334  " [code=" + itos(status) + "]",
335  "specsReadParallel" );
336  // specsMaster() -> reset();
337  }
338  else {
339  verbose("Word " + itos(parallelBus) +
340  " successfully read at address " + itos(add),
341  "SpecsReadParallel");
342  }
343 #else
344  verbose("Compilation in _NODEVICE_ mode.",
345  "SpecsReadParallel");
346 #endif
347  return true;
348 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
void add(int attribut)
Definition: Attrib.h:67
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsReadRegister()

bool SpecsInterface::specsReadRegister ( unsigned char  reg,
U16 value 
)

Read Register data

Returns
bool
Parameters
[in]registerregister number
[in]datadata

Definition at line 383 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

Referenced by SpecsMezzanine::cmdline(), SpecsGlue::date(), SpecsMezzanine::date(), SpecsGlue::i2cClkMode(), SpecsGlue::led(), SpecsMezzanine::led(), SpecsGlue::setI2cClkMode(), SpecsGlue::setLed(), and SpecsMezzanine::setLed().

384  {
385 #ifndef _NODEVICE_
386  SPECSSLAVE *specsSlv=specsSlaveDevice();
387 
388  if ( 0==specsSlv ){
389  warning("Could not reach proper SpecsSlave/Master.",
390  "SpecsInterface::specsReadRegister");
391  return false;
392  }
393 
394  SpecsError status ;
395  status = specs_register_read ( specsSlv , reg , &value );
396  if (0!=status){
397  warning("failure at register " + itos (reg) +
398  " [code=" + itos(status) + "]" ,
399  "specsReadRegister");
400  // specsMaster() -> reset();
401  return false;
402  }
403  else {
404  verbose("register " + itos(reg) +
405  " successfully read with value " + itos(value),
406  "SpecsReadRegister");
407  }
408 #else
409  verbose("Compilation in _NODEVICE_ mode.",
410  "SpecsInterface::specsReadRegister");
411 #endif
412  return true;
413 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsSlave()

SpecsSlave * SpecsInterface::specsSlave ( )
virtual

Get the closest slave in the element hierarchy

Returns
SpecsSlave

Definition at line 49 of file SpecsInterface.cpp.

References Hierarchy::parent(), and specsSlave().

Referenced by BOOST_PYTHON_MODULE(), SpecsSlave::detect(), SpecsSlave::init(), SpecsSlave::setAddress(), specsSlave(), and SpecsSlave::specsSlaveDevice().

49  {
50  if (0!=parent()){
51  SpecsInterface* tmp = dynamic_cast <SpecsInterface*> (parent());
52  if ( 0 != tmp ) return tmp->specsSlave();
53  }
54  return (SpecsSlave*)NULL;
55 }
Hierarchy * parent()
Definition: Hierarchy.h:28
virtual SpecsSlave * specsSlave()

◆ specsSlaveDevice()

SPECSSLAVE * SpecsInterface::specsSlaveDevice ( )
virtual

Get the closest slave in the element hierarchy

Returns
SPECSSLAVE*

Reimplemented in SpecsSlave.

Definition at line 66 of file SpecsInterface.cpp.

References Hierarchy::parent(), and specsSlaveDevice().

Referenced by specsReadI2c(), specsReadParallel(), specsReadRegister(), specsSlaveDevice(), specsWriteI2c(), specsWriteParallel(), and specsWriteRegister().

66  {
67  if (0!=parent()){
68  SpecsInterface* tmp = dynamic_cast <SpecsInterface*> (parent());
69  if ( 0 != tmp ) return tmp->specsSlaveDevice();
70  }
71  return (SPECSSLAVE*)NULL;
72 }
Hierarchy * parent()
Definition: Hierarchy.h:28
virtual SPECSSLAVE * specsSlaveDevice()

◆ specsWriteI2c() [1/4]

bool SpecsInterface::specsWriteI2c ( unsigned char  address,
unsigned char  nData,
U8 data 
)

Write nData stored in data to i2c slave address

Returns
bool
Parameters
[in]addressi2c Slave address
[in]nDatanumber of octets to send
[in]datacontains the data to send

Definition at line 85 of file SpecsInterface.cpp.

References itos(), outputSelect(), specsSlaveDevice(), Object::verbose(), and Object::warning().

Referenced by SpecsMezzanine::cmdline(), and specsWriteI2c().

87  {
88 #ifndef _NODEVICE_
89  SPECSSLAVE *specsSlv=specsSlaveDevice();
90  if ( 0==specsSlv ){
91  warning("Could not reach proper Specs Master and/or Slave.","SpecsInterface::specsWriteI2c");
92  return false;
93  }
94  SpecsError status = specs_i2c_write ( specsSlv, outputSelect() , i2cAdd , nWord , data );
95  if (0!=status){
96  warning("failure at address " + itos (i2cAdd) + "[code=" + itos(status) + "]" ,
97  "specsWriteI2c");
98  // specsMaster() -> reset();
99  }
100  else {
101  verbose(itos(nWord) + " words written at address " + itos(i2cAdd),
102  "SpecsWriteI2c");
103  }
104 #else
105  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsWriteI2c");
106 #endif
107  return true;
108 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
def data(object, stream=None)
Definition: shell.py:150
virtual SPECSSLAVE * specsSlaveDevice()
unsigned char outputSelect()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsWriteI2c() [2/4]

bool SpecsInterface::specsWriteI2c ( unsigned char  address,
std::vector< U8 data 
)

Write data to i2c slave address

Returns
bool
Parameters
[in]addressi2c Slave address
[in]datacontains the data to send

Definition at line 111 of file SpecsInterface.cpp.

References specsWriteI2c(), and Object::warning().

112  {
113 
114  unsigned char nword = static_cast<unsigned int>( data.size() );
115  if ( nword == 0 ) {
116  warning("Request to write data of size 0","SpecsInterface::specsWriteI2c");
117  return false;
118  }
119  unsigned char* new_data = new unsigned char[nword];
120  for(unsigned int i=0; i<data.size(); ++i) new_data[i] = data[i];
121 
122  bool status = specsWriteI2c(address, nword, new_data);
123  delete [] new_data;
124  return status;
125 
126  return true;
127 }
bool specsWriteI2c(unsigned char address, unsigned char nData, U8 *data)
unsigned char address()
def data(object, stream=None)
Definition: shell.py:150
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsWriteI2c() [3/4]

bool SpecsInterface::specsWriteI2c ( unsigned char  address,
unsigned char  subAddress,
unsigned char  nData,
U8 data 
)

Write nData stored in data to i2c slave address at subAddress

Returns
bool
Parameters
[in]addressi2c Slave address
[in]nDatanumber of octets to send
[in]datacontains the data to send

Definition at line 129 of file SpecsInterface.cpp.

References itos(), outputSelect(), specsSlaveDevice(), Object::verbose(), and Object::warning().

132  {
133 #ifndef _NODEVICE_
134  SPECSSLAVE *specsSlv=specsSlaveDevice();
135  if ( 0==specsSlv ){
136  warning("Could not reach proper Specs Master and/or Slave.","SpecsInterface::specsWriteI2c");
137  return false;
138  }
139  SpecsError status = specs_i2c_write_sub ( specsSlv, outputSelect() , i2cAdd , subAdd , nWord , data );
140  if (0!=status){
141  warning("failure at address " + itos (i2cAdd) + "/ subAddress " + itos(subAdd) +
142  " [code=" + itos(status) + "]","specsWriteI2c");
143  // specsMaster() -> reset();
144  }
145  else {
146  verbose(itos(nWord) +
147  " words written at address " +
148  itos(i2cAdd) +
149  "/ subAddress " +
150  itos(subAdd),
151  "SpecsWriteI2c");
152  }
153 #else
154  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsWriteI2c");
155 #endif
156  return true;
157 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
def data(object, stream=None)
Definition: shell.py:150
virtual SPECSSLAVE * specsSlaveDevice()
unsigned char outputSelect()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsWriteI2c() [4/4]

bool SpecsInterface::specsWriteI2c ( unsigned char  address,
unsigned char  outputSel,
unsigned char  subAddress,
unsigned char  nData,
U8 data 
)

Write nData stored in data to i2c slave address at subAddress

Returns
bool
Parameters
[in]addressi2c Slave address
[in]outputSeli2c Slave output select
[in]nDatanumber of octets to send
[in]datacontains the data to send

Definition at line 159 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

163  {
164 #ifndef _NODEVICE_
165  SPECSSLAVE *specsSlv=specsSlaveDevice();
166  if ( 0==specsSlv ){
167  warning("Could not reach proper Specs Master and/or Slave.",
168  "SpecsInterface::specsWriteI2c");
169  return false;
170  }
171  SpecsError status = specs_i2c_write_sub ( specsSlv, outputSel ,
172  i2cAdd , subAdd ,
173  nWord , data );
174  if (0!=status){
175  warning("failure at address " + itos (i2cAdd) + "/ subAddress " + itos(subAdd) +
176  " [code=" + itos(status) + "]" ,
177  "specsWriteI2c");
178  // specsMaster() -> reset();
179  }
180  else {
181  verbose(itos(nWord) + " words written at address " + itos(i2cAdd) +
182  "/ subAddress " + itos(subAdd),
183  "SpecsWriteI2c");
184  }
185 #else
186  verbose("Compilation in _NODEVICE_ mode.","SpecsInterface::specsWriteI2c");
187 #endif
188  return true;
189 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
def data(object, stream=None)
Definition: shell.py:150
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsWriteParallel()

bool SpecsInterface::specsWriteParallel ( unsigned char  address,
unsigned short  data 
)

Write address / data on parallel bus

Returns
bool
Parameters
[in]addressaddress bus
[in]datadata bus

Definition at line 295 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

296  {
297 #ifndef _NODEVICE_
298  SPECSSLAVE *specsSlv=specsSlaveDevice();
299  if ( 0==specsSlv ){
300  warning("Could not reach proper Specs Master and/or Slave.",
301  "SpecsInterface::specsWriteParallel");
302  return false;
303  }
304  SpecsError status = specs_parallel_write( specsSlv , add , 1 , &value );
305  if (0!=status){
306  warning("failure at address " + itos (add) +
307  " [code=" + itos(status) + "]" ,
308  "specsWriteParallel");
309  // specsMaster() -> reset();
310  }
311  else {
312  verbose("Word " + itos( value ) +
313  " successfully written at address " + itos(add),
314  "SpecsWriteParallel");
315  }
316 #else
317  verbose("Compilation in _NODEVICE_ mode.",
318  "SpecsWriteParallel");
319 #endif
320  return true;
321 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
void add(int attribut)
Definition: Attrib.h:67
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ specsWriteRegister()

bool SpecsInterface::specsWriteRegister ( unsigned char  reg,
unsigned short  value 
)

Write Register data

Returns
bool
Parameters
[in]registerregister number
[in]datadata bus

Definition at line 351 of file SpecsInterface.cpp.

References itos(), specsSlaveDevice(), Object::verbose(), and Object::warning().

Referenced by SpecsMezzanine::cmdline(), SpecsGlue::setI2cClkMode(), SpecsGlue::setLed(), and SpecsMezzanine::setLed().

352  {
353 #ifndef _NODEVICE_
354  SPECSSLAVE *specsSlv=specsSlaveDevice();
355 
356  if ( 0==specsSlv ){
357  warning("Could not reach proper SpecsSlave/Master.",
358  "SpecsInterface::specsWriteRegister");
359  return false;
360  }
361 
362  SpecsError status ;
363  status = specs_register_write ( specsSlv , reg , value );
364  if ( 0 != status ){
365  warning("failure at register " + itos (reg) +
366  " [code=" + itos(status) + "]" ,
367  "specsWriteRegister");
368  // specsMaster() -> reset();
369  return false;
370  }
371  else {
372  verbose("register " + itos(reg) +
373  " successfully written with value " + itos (value),
374  "SpecsWriteRegister");
375  }
376 #else
377  verbose("Compilation in _NODEVICE_ mode.",
378  "SpecsInterface::specsWriteRegister");
379 #endif
380  return true;
381 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
virtual SPECSSLAVE * specsSlaveDevice()
void warning(std::string mymsg)
Definition: Object.h:39

◆ update()

virtual void SpecsInterface::update ( )
inlinevirtual

Update the Element configuration from the actual hardware

Implements Interface.

Reimplemented in SpecsParallelBus.

Definition at line 86 of file SpecsInterface.h.

Referenced by BOOST_PYTHON_MODULE().

86 {info("SpecsInterface "+name()+". Nothing to do.","SpecsInterface::update");};
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ write()

virtual StatusCode SpecsInterface::write ( IOdata io)
inlinevirtual

Implements Interface.

Definition at line 125 of file SpecsInterface.h.

References shell::data(), and StatusCode::SUCCESS.

Member Data Documentation

◆ m_address

unsigned char SpecsInterface::m_address
protected

Definition at line 268 of file SpecsInterface.h.

Referenced by address(), SpecsSlave::setAddress(), setAddress(), and SpecsInterface().

◆ m_outputSelect

unsigned char SpecsInterface::m_outputSelect
protected

Definition at line 269 of file SpecsInterface.h.

Referenced by outputSelect(), setOutputSelect(), and SpecsInterface().

◆ m_slot

int SpecsInterface::m_slot
private

Definition at line 266 of file SpecsInterface.h.


The documentation for this class was generated from the following files: