├── .gitignore ├── extras ├── CEC_Specs.pdf ├── CEC_Interface.fzz ├── CEC_Electrical.png └── CEC_keylist.fods ├── Common.h ├── CEC_Device.h ├── Serial.h ├── Common.cpp ├── README.md ├── CEC.h ├── CEC_Device.cpp ├── Serial.cpp ├── CEC_Electrical.h ├── examples └── CEC │ └── CEC.ino ├── CEC.cpp ├── .tags ├── LICENSE └── CEC_Electrical.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | -------------------------------------------------------------------------------- /extras/CEC_Specs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floe/CEC/HEAD/extras/CEC_Specs.pdf -------------------------------------------------------------------------------- /extras/CEC_Interface.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floe/CEC/HEAD/extras/CEC_Interface.fzz -------------------------------------------------------------------------------- /extras/CEC_Electrical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floe/CEC/HEAD/extras/CEC_Electrical.png -------------------------------------------------------------------------------- /Common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H__ 2 | #define COMMON_H__ 3 | 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | 9 | #define ASSERT(x) assert(x) 10 | void DbgPrint(const char* fmt, ...); 11 | 12 | #else 13 | 14 | #define ASSERT(x) ((void)0) 15 | void DbgPrint(const char* fmt, ...); 16 | #define NULL 0 17 | 18 | #endif 19 | 20 | extern "C" 21 | { 22 | extern unsigned long micros(); 23 | extern void delayMicroseconds(unsigned int); 24 | } 25 | 26 | #endif // COMMON_H__ 27 | -------------------------------------------------------------------------------- /CEC_Device.h: -------------------------------------------------------------------------------- 1 | #ifndef CEC_DEVICE_H__ 2 | #define CEC_DEVICE_H__ 3 | 4 | #include "CEC.h" 5 | 6 | class CEC_Device : public CEC_LogicalDevice 7 | { 8 | public: 9 | CEC_Device(int physicalAddress, int in_line, int out_line); 10 | 11 | void Initialize(CEC_DEVICE_TYPE type); 12 | virtual void Run(); 13 | 14 | protected: 15 | virtual bool LineState(); 16 | virtual void SetLineState(bool); 17 | virtual void SignalIRQ(); 18 | virtual bool IsISRTriggered(); 19 | virtual bool IsISRTriggered2() { return _isrTriggered; } 20 | 21 | virtual void OnReady(); 22 | virtual void OnReceive(int source, int dest, unsigned char* buffer, int count); 23 | 24 | private: 25 | bool _isrTriggered; 26 | bool _lastLineState2; 27 | int _in_line, _out_line; 28 | }; 29 | 30 | #endif // CEC_DEVICE_H__ 31 | -------------------------------------------------------------------------------- /Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIAL_H__ 2 | #define SERIAL_H__ 3 | 4 | #include "Common.h" 5 | 6 | #define SERIAL_BUFFER_SIZE 16 7 | 8 | class SerialLine 9 | { 10 | public: 11 | SerialLine(); 12 | 13 | void ClearTransmitBuffer(); 14 | virtual bool Transmit(unsigned char* buffer, int count); 15 | virtual bool TransmitPartial(unsigned char* buffer, int count); 16 | void RegisterReceiveHandler(); 17 | 18 | protected: 19 | unsigned char _transmitBuffer[SERIAL_BUFFER_SIZE]; 20 | unsigned char _receiveBuffer[SERIAL_BUFFER_SIZE]; 21 | int _transmitBufferCount; 22 | int _transmitBufferBit; 23 | int _transmitBufferByte; 24 | int _receiveBufferCount; 25 | int _receiveBufferBit; 26 | int _receiveBufferByte; 27 | 28 | virtual void OnTransmitBegin() {;} 29 | virtual void OnReceiveComplete(unsigned char* buffer, int count); 30 | 31 | int PopTransmitBit(); 32 | int RemainingTransmitBytes(); 33 | int TransmitSize(); 34 | void ResetTransmitBuffer(); 35 | 36 | void PushReceiveBit(int); 37 | int ReceivedBytes(); 38 | void ResetReceiveBuffer(); 39 | }; 40 | 41 | #endif // SERIAL_H__ 42 | -------------------------------------------------------------------------------- /Common.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Common.h" 3 | 4 | #ifdef WIN32 5 | 6 | static char FormatBuffer[4096]; 7 | static CRITICAL_SECTION CriticalSection; 8 | static bool CriticalSectionInitialized = false; 9 | 10 | void DbgPrint(const char* fmt, ...) 11 | { 12 | va_list args; 13 | 14 | if (!CriticalSectionInitialized) 15 | { 16 | InitializeCriticalSection(&CriticalSection); 17 | CriticalSectionInitialized = true; 18 | } 19 | 20 | EnterCriticalSection(&CriticalSection); 21 | 22 | va_start(args, fmt); 23 | vsprintf_s(FormatBuffer, 4096, fmt, args); 24 | OutputDebugStringA(FormatBuffer); 25 | 26 | LeaveCriticalSection(&CriticalSection); 27 | } 28 | 29 | #else 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | void DbgPrint(const char* fmt, ...) 39 | { 40 | char FormatBuffer[128]; 41 | va_list args; 42 | va_start(args, fmt); 43 | vsprintf(FormatBuffer, fmt, args); 44 | 45 | char c; 46 | char* addr = FormatBuffer; 47 | 48 | while ((c = *addr++)) 49 | { 50 | Serial.print(c); 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CEC 2 | Arduino library for HDMI CEC communication 3 | 4 | Original code at: https://code.google.com/archive/p/cec-arduino/ (c) Phil Burr and Andrew N. Carr 5 | 6 | This is an Arduino library which implements the HDMI v1.3a CEC wire protocol which allows communication with HDMI CEC capable devices. A typical usage scenario would be a Home Theater PC environment which uses HDMI but does not support CEC. This would allow the HTPC to communicate with other HDMI CEC equipment. 7 | 8 | Note: the nice thing about CEC is that it's a bus. Consequently, the Arduino can be connected to a different HDMI port (= "physical address") than the one it should control. Therefore, the address given in the example code is the address of the port where the CEC-less source device is plugged in. 9 | 10 | I have tested the example with a somewhat dated Philips TV (40PFL5605K), and can now use my remote control for Kodi etc. Other TVs may have different quirks - if it doesn't work, connect something that does work (e.g. a FireTV), enable promiscuous mode and observe the traffic on the serial console. Unknown messages can be directly pasted into CEC-O-MATIC (http://www.cec-o-matic.com/) to decode them without having to dig through the spec. 11 | 12 | Note: most HDMI sinks also want +5V supplied on pin 18 before they start using the port. The bold numbers in the schematic below correspond to the HDMI pin numbers where the signals should be connected (see also https://en.wikipedia.org/wiki/HDMI). 13 | 14 | ![Schematic](https://raw.githubusercontent.com/floe/CEC/master/extras/CEC_Electrical.png) 15 | -------------------------------------------------------------------------------- /CEC.h: -------------------------------------------------------------------------------- 1 | #ifndef CEC_H__ 2 | #define CEC_H__ 3 | 4 | #include "CEC_Electrical.h" 5 | 6 | class CEC_LogicalDevice : public CEC_Electrical 7 | { 8 | public: 9 | typedef enum { 10 | CDT_TV, 11 | CDT_RECORDING_DEVICE, 12 | CDT_PLAYBACK_DEVICE, 13 | CDT_TUNER, 14 | CDT_AUDIO_SYSTEM, 15 | CDT_OTHER, // Not a real CEC type.. 16 | } CEC_DEVICE_TYPE; 17 | 18 | public: 19 | CEC_LogicalDevice(int physicalAddress); 20 | void Initialize(CEC_DEVICE_TYPE type); 21 | 22 | virtual void Run(); 23 | virtual bool TransmitFrame(int targetAddress, unsigned char* buffer, int count); 24 | 25 | protected: 26 | virtual bool IsISRTriggered() = 0; 27 | 28 | bool ProcessStateMachine(bool* success); 29 | 30 | virtual void OnReceiveComplete(unsigned char* buffer, int count); 31 | virtual void OnTransmitComplete(bool); 32 | 33 | virtual void OnReady() {;} 34 | virtual void OnReceive(int sourceAddress, int targetAddress, unsigned char* buffer, int count) = 0; 35 | 36 | private: 37 | typedef enum { 38 | CLA_TV = 0, 39 | CLA_RECORDING_DEVICE_1, 40 | CLA_RECORDING_DEVICE_2, 41 | CLA_TUNER_1, 42 | CLA_PLAYBACK_DEVICE_1, 43 | CLA_AUDIO_SYSTEM, 44 | CLA_TUNER_2, 45 | CLA_TUNER_3, 46 | CLA_PLAYBACK_DEVICE_2, 47 | CLA_RECORDING_DEVICE_3, 48 | CLA_TUNER_4, 49 | CLA_PLAYBACK_DEVICE_3, 50 | CLA_RESERVED_1, 51 | CLA_RESERVED_2, 52 | CLA_FREE_USE, 53 | CLA_UNREGISTERED, 54 | } CEC_LOGICAL_ADDRESS; 55 | 56 | typedef enum { 57 | CEC_IDLE, 58 | CEC_READY, 59 | CEC_ALLOCATE_LOGICAL_ADDRESS, 60 | } CEC_PRIMARY_STATE; 61 | 62 | typedef enum { 63 | CEC_XMIT_POLLING_MESSAGE, 64 | CEC_RCV_POLLING_MESSAGE, 65 | } CEC_SECONDARY_STATE; 66 | 67 | typedef enum { 68 | } CEC_TERTIARY_STATE; 69 | 70 | protected: 71 | static int _validLogicalAddresses[6][5]; 72 | int _logicalAddress; 73 | int _physicalAddress; 74 | unsigned long _waitTime; 75 | bool _done; 76 | 77 | CEC_DEVICE_TYPE _deviceType; 78 | CEC_PRIMARY_STATE _primaryState; 79 | CEC_SECONDARY_STATE _secondaryState; 80 | int _tertiaryState; 81 | 82 | }; 83 | 84 | #endif // CEC_H__ 85 | -------------------------------------------------------------------------------- /CEC_Device.cpp: -------------------------------------------------------------------------------- 1 | #include "CEC_Device.h" 2 | #include 3 | 4 | CEC_Device::CEC_Device(int physicalAddress, int in_line, int out_line) 5 | : CEC_LogicalDevice(physicalAddress) 6 | , _isrTriggered(false) 7 | , _lastLineState2(true) 8 | , _in_line(in_line) 9 | , _out_line(out_line) 10 | { 11 | } 12 | 13 | void CEC_Device::Initialize(CEC_DEVICE_TYPE type) 14 | { 15 | pinMode(_out_line, OUTPUT); 16 | pinMode( _in_line, INPUT); 17 | 18 | digitalWrite(_out_line, LOW); 19 | delay(200); 20 | 21 | CEC_LogicalDevice::Initialize(type); 22 | } 23 | 24 | void CEC_Device::OnReady() 25 | { 26 | // This is called after the logical address has been 27 | // allocated 28 | DbgPrint("Device ready\n"); 29 | } 30 | 31 | void CEC_Device::OnReceive(int source, int dest, unsigned char* buffer, int count) 32 | { 33 | // This is called when a frame is received. To transmit 34 | // a frame call TransmitFrame. To receive all frames, even 35 | // those not addressed to this device, set Promiscuous to true. 36 | DbgPrint("Packet received at %ld: %02d -> %02d: %02X", millis(), source, dest, ((source&0x0f)<<4)|(dest&0x0f)); 37 | for (int i = 0; i < count; i++) 38 | DbgPrint(":%02X", buffer[i]); 39 | DbgPrint("\n"); 40 | } 41 | 42 | bool CEC_Device::LineState() 43 | { 44 | int state = digitalRead(_in_line); 45 | return state == LOW; 46 | } 47 | 48 | void CEC_Device::SetLineState(bool state) 49 | { 50 | digitalWrite(_out_line, state?LOW:HIGH); 51 | // give enough time for the line to settle before sampling 52 | // it 53 | delayMicroseconds(50); 54 | _lastLineState2 = LineState(); 55 | } 56 | 57 | void CEC_Device::SignalIRQ() 58 | { 59 | // This is called when the line has changed state 60 | _isrTriggered = true; 61 | } 62 | 63 | bool CEC_Device::IsISRTriggered() 64 | { 65 | if (_isrTriggered) 66 | { 67 | _isrTriggered = false; 68 | return true; 69 | } 70 | return false; 71 | } 72 | 73 | void CEC_Device::Run() 74 | { 75 | bool state = LineState(); 76 | if (_lastLineState2 != state) 77 | { 78 | _lastLineState2 = state; 79 | SignalIRQ(); 80 | } 81 | CEC_LogicalDevice::Run(); 82 | } 83 | -------------------------------------------------------------------------------- /Serial.cpp: -------------------------------------------------------------------------------- 1 | #include "Serial.h" 2 | 3 | SerialLine::SerialLine() 4 | { 5 | _transmitBufferCount = 0; 6 | _transmitBufferBit = 7; 7 | _transmitBufferByte = 0; 8 | _receiveBufferCount = 0; 9 | _receiveBufferBit = 7; 10 | _receiveBufferByte = 0; 11 | } 12 | 13 | void SerialLine::OnReceiveComplete(unsigned char* buffer, int count) 14 | { 15 | ResetReceiveBuffer(); 16 | } 17 | 18 | void SerialLine::ClearTransmitBuffer() 19 | { 20 | _transmitBufferCount = 0; 21 | _transmitBufferBit = 7; 22 | _transmitBufferByte = 0; 23 | } 24 | 25 | bool SerialLine::Transmit(unsigned char* buffer, int count) 26 | { 27 | if (!TransmitPartial(buffer, count)) 28 | return false; 29 | 30 | OnTransmitBegin(); 31 | return true; 32 | } 33 | 34 | bool SerialLine::TransmitPartial(unsigned char* buffer, int count) 35 | { 36 | if (count < 0 || count >= (SERIAL_BUFFER_SIZE - _transmitBufferCount)) 37 | return false; 38 | 39 | for (int i = 0; i < count; i++) 40 | _transmitBuffer[_transmitBufferCount + i] = buffer[i]; 41 | _transmitBufferCount += count; 42 | _transmitBufferBit = 7; 43 | _transmitBufferByte = 0; 44 | return true; 45 | } 46 | 47 | int SerialLine::PopTransmitBit() 48 | { 49 | if (_transmitBufferByte == _transmitBufferCount) 50 | return 0; 51 | 52 | int bit = (_transmitBuffer[_transmitBufferByte] >> _transmitBufferBit) & 1; 53 | if( _transmitBufferBit-- == 0 ) 54 | { 55 | _transmitBufferBit = 7; 56 | _transmitBufferByte++; 57 | } 58 | return bit; 59 | } 60 | 61 | int SerialLine::RemainingTransmitBytes() 62 | { 63 | return _transmitBufferCount - _transmitBufferByte; 64 | } 65 | 66 | int SerialLine::TransmitSize() 67 | { 68 | return _transmitBufferCount; 69 | } 70 | 71 | void SerialLine::PushReceiveBit(int bit) 72 | { 73 | _receiveBuffer[_receiveBufferByte] &= ~(1 << _receiveBufferBit); 74 | _receiveBuffer[_receiveBufferByte] |= bit << _receiveBufferBit; 75 | if (_receiveBufferBit-- == 0) 76 | { 77 | _receiveBufferBit = 7; 78 | _receiveBufferByte++; 79 | } 80 | } 81 | 82 | int SerialLine::ReceivedBytes() 83 | { 84 | return _receiveBufferByte; 85 | } 86 | 87 | void SerialLine::ResetReceiveBuffer() 88 | { 89 | _receiveBufferBit = 7; 90 | _receiveBufferByte = 0; 91 | } 92 | 93 | void SerialLine::ResetTransmitBuffer() 94 | { 95 | _transmitBufferBit = 7; 96 | _transmitBufferByte = 0; 97 | } -------------------------------------------------------------------------------- /CEC_Electrical.h: -------------------------------------------------------------------------------- 1 | #ifndef CECWIRE_H__ 2 | #define CECWIRE_H__ 3 | 4 | #include "Serial.h" 5 | 6 | #define CEC_MAX_RETRANSMIT 5 7 | 8 | class CEC_Electrical : public SerialLine 9 | { 10 | public: 11 | CEC_Electrical(int address); 12 | void Initialize(); 13 | void SetAddress(int address); 14 | 15 | unsigned long Process(); 16 | bool TransmitPending() { return _primaryState == CEC_TRANSMIT && _secondaryState == CEC_IDLE_WAIT; } 17 | 18 | int Promiscuous; 19 | int MonitorMode; 20 | 21 | protected: 22 | virtual bool LineState() = 0; 23 | virtual void SetLineState(bool) = 0; 24 | 25 | private: 26 | typedef enum { 27 | CEC_IDLE, 28 | CEC_TRANSMIT, 29 | CEC_RECEIVE, 30 | } CEC_PRIMARY_STATE; 31 | 32 | typedef enum { 33 | CEC_RCV_STARTBIT1, 34 | CEC_RCV_STARTBIT2, 35 | CEC_RCV_DATABIT1, 36 | CEC_RCV_DATABIT2, 37 | CEC_RCV_ACK_SENT, 38 | CEC_RCV_ACK1, 39 | CEC_RCV_ACK2, 40 | CEC_RCV_LINEERROR, 41 | 42 | CEC_IDLE_WAIT, 43 | CEC_XMIT_STARTBIT1, 44 | CEC_XMIT_STARTBIT2, 45 | CEC_XMIT_DATABIT1, 46 | CEC_XMIT_DATABIT2, 47 | CEC_XMIT_ACK, 48 | CEC_XMIT_ACK2, 49 | CEC_XMIT_ACK3, 50 | CEC_XMIT_ACK_TEST, 51 | } CEC_SECONDARY_STATE; 52 | 53 | typedef enum { 54 | CEC_RCV_BIT0, 55 | CEC_RCV_BIT1, 56 | CEC_RCV_BIT2, 57 | CEC_RCV_BIT3, 58 | CEC_RCV_BIT4, 59 | CEC_RCV_BIT5, 60 | CEC_RCV_BIT6, 61 | CEC_RCV_BIT7, 62 | CEC_RCV_BIT_EOM, 63 | CEC_RCV_BIT_ACK, 64 | 65 | CEC_ACK, 66 | CEC_NAK, 67 | 68 | CEC_XMIT_BIT0, 69 | CEC_XMIT_BIT1, 70 | CEC_XMIT_BIT2, 71 | CEC_XMIT_BIT3, 72 | CEC_XMIT_BIT4, 73 | CEC_XMIT_BIT5, 74 | CEC_XMIT_BIT6, 75 | CEC_XMIT_BIT7, 76 | CEC_XMIT_BIT_EOM, 77 | CEC_XMIT_BIT_ACK, 78 | 79 | 80 | CEC_IDLE_RETRANSMIT_FRAME, 81 | CEC_IDLE_NEW_FRAME, 82 | CEC_IDLE_SUBSEQUENT_FRAME, 83 | } CEC_TERTIARY_STATE; 84 | 85 | private: 86 | bool ResetState(); 87 | void ResetTransmit(bool retransmit); 88 | virtual void OnTransmitBegin(); 89 | virtual void OnTransmitComplete(bool); 90 | 91 | void ProcessFrame(); 92 | 93 | // Helper functions 94 | bool Raise(); 95 | bool Lower(); 96 | void HasRaised(unsigned long); 97 | void HasLowered(unsigned long); 98 | bool CheckAddress(); 99 | void ReceivedBit(bool); 100 | unsigned long LineError(); 101 | 102 | int _address; 103 | 104 | bool _lastLineState; 105 | unsigned long _lastStateChangeTime; 106 | unsigned long _bitStartTime; 107 | 108 | int _xmitretry; 109 | 110 | bool _eom; 111 | bool _follower; 112 | bool _broadcast; 113 | bool _amLastTransmittor; 114 | bool _transmitPending; 115 | 116 | CEC_PRIMARY_STATE _primaryState; 117 | CEC_SECONDARY_STATE _secondaryState; 118 | CEC_TERTIARY_STATE _tertiaryState; 119 | }; 120 | 121 | 122 | 123 | #endif // CECWIRE_H__ 124 | -------------------------------------------------------------------------------- /examples/CEC/CEC.ino: -------------------------------------------------------------------------------- 1 | #include "CEC_Device.h" 2 | 3 | #define IN_LINE 2 4 | #define OUT_LINE 3 5 | #define HPD_LINE 10 6 | 7 | // ugly macro to do debug printing in the OnReceive method 8 | #define report(X) do { DbgPrint("report " #X "\n"); report ## X (); } while (0) 9 | 10 | #define phy1 ((_physicalAddress >> 8) & 0xFF) 11 | #define phy2 ((_physicalAddress >> 0) & 0xFF) 12 | 13 | class MyCEC: public CEC_Device { 14 | public: 15 | MyCEC(int physAddr): CEC_Device(physAddr,IN_LINE,OUT_LINE) { } 16 | 17 | void reportPhysAddr() { unsigned char frame[4] = { 0x84, phy1, phy2, 0x04 }; TransmitFrame(0x0F,frame,sizeof(frame)); } // report physical address 18 | void reportStreamState() { unsigned char frame[3] = { 0x82, phy1, phy2 }; TransmitFrame(0x0F,frame,sizeof(frame)); } // report stream state (playing) 19 | 20 | void reportPowerState() { unsigned char frame[2] = { 0x90, 0x00 }; TransmitFrame(0x00,frame,sizeof(frame)); } // report power state (on) 21 | void reportCECVersion() { unsigned char frame[2] = { 0x9E, 0x04 }; TransmitFrame(0x00,frame,sizeof(frame)); } // report CEC version (v1.3a) 22 | 23 | void reportOSDName() { unsigned char frame[5] = { 0x47, 'H','T','P','C' }; TransmitFrame(0x00,frame,sizeof(frame)); } // FIXME: name hardcoded 24 | void reportVendorID() { unsigned char frame[4] = { 0x87, 0x00, 0xF1, 0x0E }; TransmitFrame(0x00,frame,sizeof(frame)); } // report fake vendor ID 25 | // TODO: implement menu status query (0x8D) and report (0x8E,0x00) 26 | 27 | void handleKey(unsigned char key) { 28 | switch (key) { 29 | case 0x00: Keyboard.press(KEY_RETURN); break; 30 | case 0x01: Keyboard.press(KEY_UP_ARROW); break; 31 | case 0x02: Keyboard.press(KEY_DOWN_ARROW); break; 32 | case 0x03: Keyboard.press(KEY_LEFT_ARROW); break; 33 | case 0x04: Keyboard.press(KEY_RIGHT_ARROW); break; 34 | case 0x0D: Keyboard.press(KEY_ESC); break; 35 | case 0x4B: Keyboard.press(KEY_PAGE_DOWN); break; 36 | case 0x4C: Keyboard.press(KEY_PAGE_UP); break; 37 | case 0x53: Keyboard.press(KEY_HOME); break; 38 | } 39 | } 40 | 41 | void OnReceive(int source, int dest, unsigned char* buffer, int count) { 42 | if (count == 0) return; 43 | switch (buffer[0]) { 44 | 45 | case 0x36: DbgPrint("standby\n"); break; 46 | 47 | case 0x83: report(PhysAddr); break; 48 | case 0x86: if (buffer[1] == phy1 && buffer[2] == phy2) 49 | report(StreamState); break; 50 | 51 | case 0x8F: report(PowerState); break; 52 | case 0x9F: report(CECVersion); break; 53 | 54 | case 0x46: report(OSDName); break; 55 | case 0x8C: report(VendorID); break; 56 | 57 | case 0x44: handleKey(buffer[1]); break; 58 | case 0x45: Keyboard.releaseAll(); break; 59 | 60 | default: CEC_Device::OnReceive(source,dest,buffer,count); break; 61 | } 62 | } 63 | }; 64 | 65 | // TODO: set physical address via serial (or even DDC?) 66 | 67 | // Note: this does not need to correspond to the physical address (i.e. port number) 68 | // where the Arduino is connected - in fact, it _should_ be a different port, namely 69 | // the one where the PC to be controlled is connected. Basically, it is the address 70 | // of the port where the CEC-less source device is plugged in. 71 | MyCEC device(0x1000); 72 | 73 | void setup() 74 | { 75 | // setup Hotplug pin 76 | pinMode(HPD_LINE,INPUT); 77 | 78 | Serial.begin(115200); 79 | Keyboard.begin(); 80 | 81 | //device.MonitorMode = true; 82 | //device.Promiscuous = true; 83 | device.Initialize(CEC_LogicalDevice::CDT_PLAYBACK_DEVICE); 84 | } 85 | 86 | void loop() 87 | { 88 | // FIXME: does it still work without serial connected? 89 | // try to toggle LED e.g. 90 | if (Serial.available()) 91 | { 92 | unsigned char c = Serial.read(); 93 | unsigned char buffer[2] = { c, 0 }; 94 | Serial.print("Command: "); Serial.println((const char*)buffer); 95 | 96 | switch (c) 97 | { 98 | case 'v': 99 | // request vendor ID 100 | buffer[0] = 0x8C; 101 | device.TransmitFrame(0, buffer, 1); 102 | break; 103 | case 'p': 104 | // toggle promiscuous mode 105 | device.Promiscuous = !(device.Promiscuous); 106 | break; 107 | case 'h': 108 | // query Hotplug pin 109 | Serial.print("Hotplug state: "); Serial.println(digitalRead(HPD_LINE)); 110 | break; 111 | } 112 | } 113 | device.Run(); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /CEC.cpp: -------------------------------------------------------------------------------- 1 | #include "CEC.h" 2 | 3 | int CEC_LogicalDevice::_validLogicalAddresses[6][5] = 4 | { {CLA_TV, CLA_FREE_USE, CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, }, 5 | {CLA_RECORDING_DEVICE_1, CLA_RECORDING_DEVICE_2, CLA_RECORDING_DEVICE_3, CLA_UNREGISTERED, CLA_UNREGISTERED, }, 6 | {CLA_PLAYBACK_DEVICE_1, CLA_PLAYBACK_DEVICE_2, CLA_PLAYBACK_DEVICE_3, CLA_UNREGISTERED, CLA_UNREGISTERED, }, 7 | {CLA_TUNER_1, CLA_TUNER_2, CLA_TUNER_3, CLA_TUNER_4, CLA_UNREGISTERED, }, 8 | {CLA_AUDIO_SYSTEM, CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, }, 9 | {CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, CLA_UNREGISTERED, }, 10 | }; 11 | 12 | #define MAKE_ADDRESS(s,d) ((((s) & 0xf) << 4) | ((d) & 0xf)) 13 | 14 | 15 | CEC_LogicalDevice::CEC_LogicalDevice(int physicalAddress) 16 | : CEC_Electrical(CLA_UNREGISTERED) 17 | , _physicalAddress(physicalAddress) 18 | , _logicalAddress(CLA_UNREGISTERED) 19 | , _done(false) 20 | , _waitTime(0) 21 | , _primaryState(CEC_ALLOCATE_LOGICAL_ADDRESS) 22 | , _deviceType(CDT_OTHER) 23 | { 24 | _secondaryState = CEC_XMIT_POLLING_MESSAGE; 25 | _tertiaryState = 0; 26 | } 27 | 28 | void CEC_LogicalDevice::Initialize(CEC_DEVICE_TYPE type) 29 | { 30 | CEC_Electrical::Initialize(); 31 | _deviceType = type; 32 | 33 | if (MonitorMode) 34 | { 35 | _primaryState = CEC_READY; 36 | } 37 | } 38 | 39 | bool CEC_LogicalDevice::ProcessStateMachine(bool* success) 40 | { 41 | unsigned char buffer[1]; 42 | bool wait = false; 43 | 44 | switch (_primaryState) 45 | { 46 | case CEC_ALLOCATE_LOGICAL_ADDRESS: 47 | switch (_secondaryState) 48 | { 49 | case CEC_XMIT_POLLING_MESSAGE: 50 | // Section 6.1.3 specifies that while allocating a Logical Address 51 | // will have the same initiator and destination address 52 | buffer[0] = MAKE_ADDRESS(_validLogicalAddresses[_deviceType][_tertiaryState], _validLogicalAddresses[_deviceType][_tertiaryState]); 53 | ClearTransmitBuffer(); 54 | Transmit(buffer, 1); 55 | 56 | _secondaryState = CEC_RCV_POLLING_MESSAGE; 57 | wait = true; 58 | break; 59 | 60 | case CEC_RCV_POLLING_MESSAGE: 61 | if (success) 62 | { 63 | if (*success) 64 | { 65 | // Someone is there, try the next 66 | _tertiaryState++; 67 | if (_validLogicalAddresses[_deviceType][_tertiaryState] != CLA_UNREGISTERED) 68 | _secondaryState = CEC_XMIT_POLLING_MESSAGE; 69 | else 70 | { 71 | _logicalAddress = CLA_UNREGISTERED; 72 | DbgPrint("Logical address assigned: %d\n", _logicalAddress); 73 | _primaryState = CEC_READY; 74 | } 75 | } 76 | else 77 | { 78 | // We hereby claim this as our logical address! 79 | _logicalAddress = _validLogicalAddresses[_deviceType][_tertiaryState]; 80 | SetAddress(_logicalAddress); 81 | DbgPrint("Logical address assigned: %d\n", _logicalAddress); 82 | _primaryState = CEC_READY; 83 | } 84 | } 85 | else 86 | wait = true; 87 | break; 88 | } 89 | break; 90 | 91 | case CEC_READY: 92 | _primaryState = CEC_IDLE; 93 | OnReady(); 94 | wait = true; 95 | break; 96 | 97 | case CEC_IDLE: 98 | wait = true; 99 | break; 100 | } 101 | 102 | return wait; 103 | } 104 | 105 | void CEC_LogicalDevice::OnReceiveComplete(unsigned char* buffer, int count) 106 | { 107 | ASSERT(count >= 1); 108 | int sourceAddress = (buffer[0] >> 4) & 0x0f; 109 | int targetAddress = buffer[0] & 0x0f; 110 | OnReceive(sourceAddress, targetAddress, buffer + 1, count - 1); 111 | } 112 | 113 | bool CEC_LogicalDevice::TransmitFrame(int targetAddress, unsigned char* buffer, int count) 114 | { 115 | if (_primaryState != CEC_IDLE) 116 | return false; 117 | 118 | unsigned char addr[1]; 119 | 120 | addr[0] = MAKE_ADDRESS(_logicalAddress, targetAddress); 121 | ClearTransmitBuffer(); 122 | if (!TransmitPartial(addr, 1)) 123 | return false; 124 | return Transmit(buffer, count); 125 | } 126 | 127 | void CEC_LogicalDevice::OnTransmitComplete(bool success) 128 | { 129 | if (_primaryState == CEC_ALLOCATE_LOGICAL_ADDRESS && 130 | _secondaryState == CEC_RCV_POLLING_MESSAGE && 131 | _logicalAddress == CLA_UNREGISTERED) 132 | { 133 | while (!ProcessStateMachine(&success)) 134 | ; 135 | } 136 | else 137 | DbgPrint("Transmit: %d\n", success); 138 | } 139 | 140 | void CEC_LogicalDevice::Run() 141 | { 142 | // Initial pump for the state machine (this will cause a transmit to occur) 143 | while (!ProcessStateMachine(NULL)) 144 | ; 145 | 146 | if (((_waitTime == (unsigned long)-1 && !TransmitPending()) || (_waitTime != (unsigned long)-1 && _waitTime > micros())) && !IsISRTriggered()) 147 | return; 148 | 149 | unsigned long wait = Process(); 150 | if (wait != (unsigned long)-2) 151 | _waitTime = wait; 152 | return; 153 | } 154 | 155 | 156 | -------------------------------------------------------------------------------- /.tags: -------------------------------------------------------------------------------- 1 | !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ 2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ 3 | !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ 4 | !_TAG_PROGRAM_NAME Exuberant Ctags // 5 | !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 6 | !_TAG_PROGRAM_VERSION 5.9~svn20110310 // 7 | ASSERT Common.h 14;" d 8 | ASSERT Common.h 9;" d 9 | CDT_AUDIO_SYSTEM CEC.h /^ CDT_AUDIO_SYSTEM,$/;" e enum:CEC_LogicalDevice::__anon1 10 | CDT_OTHER CEC.h /^ CDT_OTHER, \/\/ Not a real CEC type..$/;" e enum:CEC_LogicalDevice::__anon1 11 | CDT_PLAYBACK_DEVICE CEC.h /^ CDT_PLAYBACK_DEVICE,$/;" e enum:CEC_LogicalDevice::__anon1 12 | CDT_RECORDING_DEVICE CEC.h /^ CDT_RECORDING_DEVICE,$/;" e enum:CEC_LogicalDevice::__anon1 13 | CDT_TUNER CEC.h /^ CDT_TUNER,$/;" e enum:CEC_LogicalDevice::__anon1 14 | CDT_TV CEC.h /^ CDT_TV,$/;" e enum:CEC_LogicalDevice::__anon1 15 | CECWIRE_H__ CEC_Electrical.h 2;" d 16 | CEC_ACK CEC_Electrical.h /^ CEC_ACK,$/;" e enum:CEC_Electrical::__anon8 17 | CEC_ALLOCATE_LOGICAL_ADDRESS CEC.h /^ CEC_ALLOCATE_LOGICAL_ADDRESS,$/;" e enum:CEC_LogicalDevice::__anon3 18 | CEC_DEVICE_H__ CEC_Device.h 2;" d 19 | CEC_DEVICE_TYPE CEC.h /^ } CEC_DEVICE_TYPE;$/;" t class:CEC_LogicalDevice typeref:enum:CEC_LogicalDevice::__anon1 20 | CEC_Device CEC_Device.cpp /^CEC_Device::CEC_Device(int physicalAddress, int in_line, int out_line)$/;" f class:CEC_Device 21 | CEC_Device CEC_Device.h /^class CEC_Device : public CEC_LogicalDevice$/;" c 22 | CEC_Electrical CEC_Electrical.cpp /^CEC_Electrical::CEC_Electrical(int address)$/;" f class:CEC_Electrical 23 | CEC_Electrical CEC_Electrical.h /^class CEC_Electrical : public SerialLine$/;" c 24 | CEC_H__ CEC.h 2;" d 25 | CEC_IDLE CEC.h /^ CEC_IDLE,$/;" e enum:CEC_LogicalDevice::__anon3 26 | CEC_IDLE CEC_Electrical.h /^ CEC_IDLE,$/;" e enum:CEC_Electrical::__anon6 27 | CEC_IDLE_NEW_FRAME CEC_Electrical.h /^ CEC_IDLE_NEW_FRAME,$/;" e enum:CEC_Electrical::__anon8 28 | CEC_IDLE_RETRANSMIT_FRAME CEC_Electrical.h /^ CEC_IDLE_RETRANSMIT_FRAME,$/;" e enum:CEC_Electrical::__anon8 29 | CEC_IDLE_SUBSEQUENT_FRAME CEC_Electrical.h /^ CEC_IDLE_SUBSEQUENT_FRAME,$/;" e enum:CEC_Electrical::__anon8 30 | CEC_IDLE_WAIT CEC_Electrical.h /^ CEC_IDLE_WAIT,$/;" e enum:CEC_Electrical::__anon7 31 | CEC_LOGICAL_ADDRESS CEC.h /^ } CEC_LOGICAL_ADDRESS;$/;" t class:CEC_LogicalDevice typeref:enum:CEC_LogicalDevice::__anon2 32 | CEC_LogicalDevice CEC.cpp /^CEC_LogicalDevice::CEC_LogicalDevice(int physicalAddress)$/;" f class:CEC_LogicalDevice 33 | CEC_LogicalDevice CEC.h /^class CEC_LogicalDevice : public CEC_Electrical$/;" c 34 | CEC_MAX_RETRANSMIT CEC_Electrical.h 6;" d 35 | CEC_NAK CEC_Electrical.h /^ CEC_NAK,$/;" e enum:CEC_Electrical::__anon8 36 | CEC_PRIMARY_STATE CEC.h /^ } CEC_PRIMARY_STATE;$/;" t class:CEC_LogicalDevice typeref:enum:CEC_LogicalDevice::__anon3 37 | CEC_PRIMARY_STATE CEC_Electrical.h /^ } CEC_PRIMARY_STATE;$/;" t class:CEC_Electrical typeref:enum:CEC_Electrical::__anon6 38 | CEC_RCV_ACK1 CEC_Electrical.h /^ CEC_RCV_ACK1,$/;" e enum:CEC_Electrical::__anon7 39 | CEC_RCV_ACK2 CEC_Electrical.h /^ CEC_RCV_ACK2,$/;" e enum:CEC_Electrical::__anon7 40 | CEC_RCV_ACK_SENT CEC_Electrical.h /^ CEC_RCV_ACK_SENT,$/;" e enum:CEC_Electrical::__anon7 41 | CEC_RCV_BIT0 CEC_Electrical.h /^ CEC_RCV_BIT0,$/;" e enum:CEC_Electrical::__anon8 42 | CEC_RCV_BIT1 CEC_Electrical.h /^ CEC_RCV_BIT1,$/;" e enum:CEC_Electrical::__anon8 43 | CEC_RCV_BIT2 CEC_Electrical.h /^ CEC_RCV_BIT2,$/;" e enum:CEC_Electrical::__anon8 44 | CEC_RCV_BIT3 CEC_Electrical.h /^ CEC_RCV_BIT3,$/;" e enum:CEC_Electrical::__anon8 45 | CEC_RCV_BIT4 CEC_Electrical.h /^ CEC_RCV_BIT4,$/;" e enum:CEC_Electrical::__anon8 46 | CEC_RCV_BIT5 CEC_Electrical.h /^ CEC_RCV_BIT5,$/;" e enum:CEC_Electrical::__anon8 47 | CEC_RCV_BIT6 CEC_Electrical.h /^ CEC_RCV_BIT6,$/;" e enum:CEC_Electrical::__anon8 48 | CEC_RCV_BIT7 CEC_Electrical.h /^ CEC_RCV_BIT7,$/;" e enum:CEC_Electrical::__anon8 49 | CEC_RCV_BIT_ACK CEC_Electrical.h /^ CEC_RCV_BIT_ACK,$/;" e enum:CEC_Electrical::__anon8 50 | CEC_RCV_BIT_EOM CEC_Electrical.h /^ CEC_RCV_BIT_EOM,$/;" e enum:CEC_Electrical::__anon8 51 | CEC_RCV_DATABIT1 CEC_Electrical.h /^ CEC_RCV_DATABIT1,$/;" e enum:CEC_Electrical::__anon7 52 | CEC_RCV_DATABIT2 CEC_Electrical.h /^ CEC_RCV_DATABIT2,$/;" e enum:CEC_Electrical::__anon7 53 | CEC_RCV_LINEERROR CEC_Electrical.h /^ CEC_RCV_LINEERROR,$/;" e enum:CEC_Electrical::__anon7 54 | CEC_RCV_POLLING_MESSAGE CEC.h /^ CEC_RCV_POLLING_MESSAGE,$/;" e enum:CEC_LogicalDevice::__anon4 55 | CEC_RCV_STARTBIT1 CEC_Electrical.h /^ CEC_RCV_STARTBIT1,$/;" e enum:CEC_Electrical::__anon7 56 | CEC_RCV_STARTBIT2 CEC_Electrical.h /^ CEC_RCV_STARTBIT2,$/;" e enum:CEC_Electrical::__anon7 57 | CEC_READY CEC.h /^ CEC_READY,$/;" e enum:CEC_LogicalDevice::__anon3 58 | CEC_RECEIVE CEC_Electrical.h /^ CEC_RECEIVE,$/;" e enum:CEC_Electrical::__anon6 59 | CEC_SECONDARY_STATE CEC.h /^ } CEC_SECONDARY_STATE;$/;" t class:CEC_LogicalDevice typeref:enum:CEC_LogicalDevice::__anon4 60 | CEC_SECONDARY_STATE CEC_Electrical.h /^ } CEC_SECONDARY_STATE;$/;" t class:CEC_Electrical typeref:enum:CEC_Electrical::__anon7 61 | CEC_TERTIARY_STATE CEC.h /^ } CEC_TERTIARY_STATE;$/;" t class:CEC_LogicalDevice typeref:enum:CEC_LogicalDevice::__anon5 62 | CEC_TERTIARY_STATE CEC_Electrical.h /^ } CEC_TERTIARY_STATE;$/;" t class:CEC_Electrical typeref:enum:CEC_Electrical::__anon8 63 | CEC_TRANSMIT CEC_Electrical.h /^ CEC_TRANSMIT,$/;" e enum:CEC_Electrical::__anon6 64 | CEC_XMIT_ACK CEC_Electrical.h /^ CEC_XMIT_ACK,$/;" e enum:CEC_Electrical::__anon7 65 | CEC_XMIT_ACK2 CEC_Electrical.h /^ CEC_XMIT_ACK2,$/;" e enum:CEC_Electrical::__anon7 66 | CEC_XMIT_ACK3 CEC_Electrical.h /^ CEC_XMIT_ACK3,$/;" e enum:CEC_Electrical::__anon7 67 | CEC_XMIT_ACK_TEST CEC_Electrical.h /^ CEC_XMIT_ACK_TEST,$/;" e enum:CEC_Electrical::__anon7 68 | CEC_XMIT_BIT0 CEC_Electrical.h /^ CEC_XMIT_BIT0,$/;" e enum:CEC_Electrical::__anon8 69 | CEC_XMIT_BIT1 CEC_Electrical.h /^ CEC_XMIT_BIT1,$/;" e enum:CEC_Electrical::__anon8 70 | CEC_XMIT_BIT2 CEC_Electrical.h /^ CEC_XMIT_BIT2,$/;" e enum:CEC_Electrical::__anon8 71 | CEC_XMIT_BIT3 CEC_Electrical.h /^ CEC_XMIT_BIT3,$/;" e enum:CEC_Electrical::__anon8 72 | CEC_XMIT_BIT4 CEC_Electrical.h /^ CEC_XMIT_BIT4,$/;" e enum:CEC_Electrical::__anon8 73 | CEC_XMIT_BIT5 CEC_Electrical.h /^ CEC_XMIT_BIT5,$/;" e enum:CEC_Electrical::__anon8 74 | CEC_XMIT_BIT6 CEC_Electrical.h /^ CEC_XMIT_BIT6,$/;" e enum:CEC_Electrical::__anon8 75 | CEC_XMIT_BIT7 CEC_Electrical.h /^ CEC_XMIT_BIT7,$/;" e enum:CEC_Electrical::__anon8 76 | CEC_XMIT_BIT_ACK CEC_Electrical.h /^ CEC_XMIT_BIT_ACK,$/;" e enum:CEC_Electrical::__anon8 77 | CEC_XMIT_BIT_EOM CEC_Electrical.h /^ CEC_XMIT_BIT_EOM,$/;" e enum:CEC_Electrical::__anon8 78 | CEC_XMIT_DATABIT1 CEC_Electrical.h /^ CEC_XMIT_DATABIT1,$/;" e enum:CEC_Electrical::__anon7 79 | CEC_XMIT_DATABIT2 CEC_Electrical.h /^ CEC_XMIT_DATABIT2,$/;" e enum:CEC_Electrical::__anon7 80 | CEC_XMIT_POLLING_MESSAGE CEC.h /^ CEC_XMIT_POLLING_MESSAGE,$/;" e enum:CEC_LogicalDevice::__anon4 81 | CEC_XMIT_STARTBIT1 CEC_Electrical.h /^ CEC_XMIT_STARTBIT1,$/;" e enum:CEC_Electrical::__anon7 82 | CEC_XMIT_STARTBIT2 CEC_Electrical.h /^ CEC_XMIT_STARTBIT2,$/;" e enum:CEC_Electrical::__anon7 83 | CLA_AUDIO_SYSTEM CEC.h /^ CLA_AUDIO_SYSTEM,$/;" e enum:CEC_LogicalDevice::__anon2 84 | CLA_FREE_USE CEC.h /^ CLA_FREE_USE,$/;" e enum:CEC_LogicalDevice::__anon2 85 | CLA_PLAYBACK_DEVICE_1 CEC.h /^ CLA_PLAYBACK_DEVICE_1,$/;" e enum:CEC_LogicalDevice::__anon2 86 | CLA_PLAYBACK_DEVICE_2 CEC.h /^ CLA_PLAYBACK_DEVICE_2,$/;" e enum:CEC_LogicalDevice::__anon2 87 | CLA_PLAYBACK_DEVICE_3 CEC.h /^ CLA_PLAYBACK_DEVICE_3,$/;" e enum:CEC_LogicalDevice::__anon2 88 | CLA_RECORDING_DEVICE_1 CEC.h /^ CLA_RECORDING_DEVICE_1,$/;" e enum:CEC_LogicalDevice::__anon2 89 | CLA_RECORDING_DEVICE_2 CEC.h /^ CLA_RECORDING_DEVICE_2,$/;" e enum:CEC_LogicalDevice::__anon2 90 | CLA_RECORDING_DEVICE_3 CEC.h /^ CLA_RECORDING_DEVICE_3,$/;" e enum:CEC_LogicalDevice::__anon2 91 | CLA_RESERVED_1 CEC.h /^ CLA_RESERVED_1,$/;" e enum:CEC_LogicalDevice::__anon2 92 | CLA_RESERVED_2 CEC.h /^ CLA_RESERVED_2,$/;" e enum:CEC_LogicalDevice::__anon2 93 | CLA_TUNER_1 CEC.h /^ CLA_TUNER_1,$/;" e enum:CEC_LogicalDevice::__anon2 94 | CLA_TUNER_2 CEC.h /^ CLA_TUNER_2,$/;" e enum:CEC_LogicalDevice::__anon2 95 | CLA_TUNER_3 CEC.h /^ CLA_TUNER_3,$/;" e enum:CEC_LogicalDevice::__anon2 96 | CLA_TUNER_4 CEC.h /^ CLA_TUNER_4,$/;" e enum:CEC_LogicalDevice::__anon2 97 | CLA_TV CEC.h /^ CLA_TV = 0,$/;" e enum:CEC_LogicalDevice::__anon2 98 | CLA_UNREGISTERED CEC.h /^ CLA_UNREGISTERED,$/;" e enum:CEC_LogicalDevice::__anon2 99 | COMMON_H__ Common.h 2;" d 100 | CheckAddress CEC_Electrical.cpp /^bool CEC_Electrical::CheckAddress()$/;" f class:CEC_Electrical 101 | ClearTransmitBuffer Serial.cpp /^void SerialLine::ClearTransmitBuffer()$/;" f class:SerialLine 102 | CriticalSection Common.cpp /^static CRITICAL_SECTION CriticalSection;$/;" v file: 103 | CriticalSectionInitialized Common.cpp /^static bool CriticalSectionInitialized = false;$/;" v file: 104 | DbgPrint Common.cpp /^void DbgPrint(const char* fmt, ...)$/;" f 105 | FormatBuffer Common.cpp /^static char FormatBuffer[4096]; $/;" v file: 106 | HasLowered CEC_Electrical.cpp /^void CEC_Electrical::HasLowered(unsigned long time)$/;" f class:CEC_Electrical 107 | HasRaised CEC_Electrical.cpp /^void CEC_Electrical::HasRaised(unsigned long time)$/;" f class:CEC_Electrical 108 | Initialize CEC.cpp /^void CEC_LogicalDevice::Initialize(CEC_DEVICE_TYPE type)$/;" f class:CEC_LogicalDevice 109 | Initialize CEC_Device.cpp /^void CEC_Device::Initialize(CEC_DEVICE_TYPE type)$/;" f class:CEC_Device 110 | Initialize CEC_Electrical.cpp /^void CEC_Electrical::Initialize()$/;" f class:CEC_Electrical 111 | IsISRTriggered CEC_Device.cpp /^bool CEC_Device::IsISRTriggered()$/;" f class:CEC_Device 112 | IsISRTriggered2 CEC_Device.h /^ virtual bool IsISRTriggered2() { return _isrTriggered; }$/;" f class:CEC_Device 113 | LineError CEC_Electrical.cpp /^unsigned long CEC_Electrical::LineError()$/;" f class:CEC_Electrical 114 | LineState CEC_Device.cpp /^bool CEC_Device::LineState()$/;" f class:CEC_Device 115 | Lower CEC_Electrical.cpp /^bool CEC_Electrical::Lower()$/;" f class:CEC_Electrical 116 | MAKE_ADDRESS CEC.cpp 12;" d file: 117 | MonitorMode CEC_Electrical.h /^ int MonitorMode;$/;" m class:CEC_Electrical 118 | NULL Common.h 16;" d 119 | OnReady CEC.h /^ virtual void OnReady() {;}$/;" f class:CEC_LogicalDevice 120 | OnReady CEC_Device.cpp /^void CEC_Device::OnReady()$/;" f class:CEC_Device 121 | OnReceive CEC_Device.cpp /^void CEC_Device::OnReceive(int source, int dest, unsigned char* buffer, int count)$/;" f class:CEC_Device 122 | OnReceiveComplete CEC.cpp /^void CEC_LogicalDevice::OnReceiveComplete(unsigned char* buffer, int count)$/;" f class:CEC_LogicalDevice 123 | OnReceiveComplete Serial.cpp /^void SerialLine::OnReceiveComplete(unsigned char* buffer, int count)$/;" f class:SerialLine 124 | OnTransmitBegin CEC_Electrical.cpp /^void CEC_Electrical::OnTransmitBegin()$/;" f class:CEC_Electrical 125 | OnTransmitBegin Serial.h /^ virtual void OnTransmitBegin() {;}$/;" f class:SerialLine 126 | OnTransmitComplete CEC.cpp /^void CEC_LogicalDevice::OnTransmitComplete(bool success)$/;" f class:CEC_LogicalDevice 127 | OnTransmitComplete CEC_Electrical.cpp /^void CEC_Electrical::OnTransmitComplete(bool success)$/;" f class:CEC_Electrical 128 | PopTransmitBit Serial.cpp /^int SerialLine::PopTransmitBit()$/;" f class:SerialLine 129 | Process CEC_Electrical.cpp /^unsigned long CEC_Electrical::Process()$/;" f class:CEC_Electrical 130 | ProcessFrame CEC_Electrical.cpp /^void CEC_Electrical::ProcessFrame()$/;" f class:CEC_Electrical 131 | ProcessStateMachine CEC.cpp /^bool CEC_LogicalDevice::ProcessStateMachine(bool* success)$/;" f class:CEC_LogicalDevice 132 | Promiscuous CEC_Electrical.h /^ int Promiscuous;$/;" m class:CEC_Electrical 133 | PushReceiveBit Serial.cpp /^void SerialLine::PushReceiveBit(int bit)$/;" f class:SerialLine 134 | Raise CEC_Electrical.cpp /^bool CEC_Electrical::Raise()$/;" f class:CEC_Electrical 135 | ReceivedBit CEC_Electrical.cpp /^void CEC_Electrical::ReceivedBit(bool state)$/;" f class:CEC_Electrical 136 | ReceivedBytes Serial.cpp /^int SerialLine::ReceivedBytes()$/;" f class:SerialLine 137 | RemainingTransmitBytes Serial.cpp /^int SerialLine::RemainingTransmitBytes()$/;" f class:SerialLine 138 | ResetReceiveBuffer Serial.cpp /^void SerialLine::ResetReceiveBuffer()$/;" f class:SerialLine 139 | ResetState CEC_Electrical.cpp /^bool CEC_Electrical::ResetState()$/;" f class:CEC_Electrical 140 | ResetTransmit CEC_Electrical.cpp /^void CEC_Electrical::ResetTransmit(bool retransmit)$/;" f class:CEC_Electrical 141 | ResetTransmitBuffer Serial.cpp /^void SerialLine::ResetTransmitBuffer()$/;" f class:SerialLine 142 | Run CEC.cpp /^void CEC_LogicalDevice::Run()$/;" f class:CEC_LogicalDevice 143 | Run CEC_Device.cpp /^void CEC_Device::Run()$/;" f class:CEC_Device 144 | SERIAL_BUFFER_SIZE Serial.h 6;" d 145 | SERIAL_H__ Serial.h 2;" d 146 | SerialLine Serial.cpp /^SerialLine::SerialLine()$/;" f class:SerialLine 147 | SerialLine Serial.h /^class SerialLine$/;" c 148 | SetAddress CEC_Electrical.cpp /^void CEC_Electrical::SetAddress(int address)$/;" f class:CEC_Electrical 149 | SetLineState CEC_Device.cpp /^void CEC_Device::SetLineState(bool state)$/;" f class:CEC_Device 150 | SignalIRQ CEC_Device.cpp /^void CEC_Device::SignalIRQ()$/;" f class:CEC_Device 151 | Transmit Serial.cpp /^bool SerialLine::Transmit(unsigned char* buffer, int count)$/;" f class:SerialLine 152 | TransmitFrame CEC.cpp /^bool CEC_LogicalDevice::TransmitFrame(int targetAddress, unsigned char* buffer, int count)$/;" f class:CEC_LogicalDevice 153 | TransmitPartial Serial.cpp /^bool SerialLine::TransmitPartial(unsigned char* buffer, int count)$/;" f class:SerialLine 154 | TransmitPending CEC_Electrical.h /^ bool TransmitPending() { return _primaryState == CEC_TRANSMIT && _secondaryState == CEC_IDLE_WAIT; }$/;" f class:CEC_Electrical 155 | TransmitSize Serial.cpp /^int SerialLine::TransmitSize()$/;" f class:SerialLine 156 | _address CEC_Electrical.h /^ int _address;$/;" m class:CEC_Electrical 157 | _amLastTransmittor CEC_Electrical.h /^ bool _amLastTransmittor;$/;" m class:CEC_Electrical 158 | _bitStartTime CEC_Electrical.h /^ unsigned long _bitStartTime;$/;" m class:CEC_Electrical 159 | _broadcast CEC_Electrical.h /^ bool _broadcast;$/;" m class:CEC_Electrical 160 | _deviceType CEC.h /^ CEC_DEVICE_TYPE _deviceType;$/;" m class:CEC_LogicalDevice 161 | _done CEC.h /^ bool _done;$/;" m class:CEC_LogicalDevice 162 | _eom CEC_Electrical.h /^ bool _eom;$/;" m class:CEC_Electrical 163 | _follower CEC_Electrical.h /^ bool _follower;$/;" m class:CEC_Electrical 164 | _in_line CEC_Device.h /^ int _in_line, _out_line;$/;" m class:CEC_Device 165 | _isrTriggered CEC_Device.h /^ bool _isrTriggered;$/;" m class:CEC_Device 166 | _lastLineState CEC_Electrical.h /^ bool _lastLineState;$/;" m class:CEC_Electrical 167 | _lastLineState2 CEC_Device.h /^ bool _lastLineState2;$/;" m class:CEC_Device 168 | _lastStateChangeTime CEC_Electrical.h /^ unsigned long _lastStateChangeTime;$/;" m class:CEC_Electrical 169 | _logicalAddress CEC.h /^ int _logicalAddress;$/;" m class:CEC_LogicalDevice 170 | _out_line CEC_Device.h /^ int _in_line, _out_line;$/;" m class:CEC_Device 171 | _physicalAddress CEC.h /^ int _physicalAddress;$/;" m class:CEC_LogicalDevice 172 | _primaryState CEC.h /^ CEC_PRIMARY_STATE _primaryState;$/;" m class:CEC_LogicalDevice 173 | _primaryState CEC_Electrical.h /^ CEC_PRIMARY_STATE _primaryState;$/;" m class:CEC_Electrical 174 | _receiveBuffer Serial.h /^ unsigned char _receiveBuffer[SERIAL_BUFFER_SIZE];$/;" m class:SerialLine 175 | _receiveBufferBit Serial.h /^ int _receiveBufferBit;$/;" m class:SerialLine 176 | _receiveBufferByte Serial.h /^ int _receiveBufferByte;$/;" m class:SerialLine 177 | _receiveBufferCount Serial.h /^ int _receiveBufferCount;$/;" m class:SerialLine 178 | _secondaryState CEC.h /^ CEC_SECONDARY_STATE _secondaryState;$/;" m class:CEC_LogicalDevice 179 | _secondaryState CEC_Electrical.h /^ CEC_SECONDARY_STATE _secondaryState;$/;" m class:CEC_Electrical 180 | _tertiaryState CEC.h /^ int _tertiaryState;$/;" m class:CEC_LogicalDevice 181 | _tertiaryState CEC_Electrical.h /^ CEC_TERTIARY_STATE _tertiaryState;$/;" m class:CEC_Electrical 182 | _transmitBuffer Serial.h /^ unsigned char _transmitBuffer[SERIAL_BUFFER_SIZE];$/;" m class:SerialLine 183 | _transmitBufferBit Serial.h /^ int _transmitBufferBit;$/;" m class:SerialLine 184 | _transmitBufferByte Serial.h /^ int _transmitBufferByte;$/;" m class:SerialLine 185 | _transmitBufferCount Serial.h /^ int _transmitBufferCount;$/;" m class:SerialLine 186 | _transmitPending CEC_Electrical.h /^ bool _transmitPending;$/;" m class:CEC_Electrical 187 | _validLogicalAddresses CEC.cpp /^int CEC_LogicalDevice::_validLogicalAddresses[6][5] = $/;" m class:CEC_LogicalDevice file: 188 | _validLogicalAddresses CEC.h /^ static int _validLogicalAddresses[6][5];$/;" m class:CEC_LogicalDevice 189 | _waitTime CEC.h /^ unsigned long _waitTime;$/;" m class:CEC_LogicalDevice 190 | _xmitretry CEC_Electrical.h /^ int _xmitretry;$/;" m class:CEC_Electrical 191 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /CEC_Electrical.cpp: -------------------------------------------------------------------------------- 1 | #include "CEC_Electrical.h" 2 | 3 | CEC_Electrical::CEC_Electrical(int address) 4 | { 5 | MonitorMode = false; 6 | Promiscuous = false; 7 | 8 | _address = address & 0x0f; 9 | _amLastTransmittor = false; 10 | _transmitPending = false; 11 | _xmitretry = 0; 12 | ResetState(); 13 | } 14 | 15 | void CEC_Electrical::Initialize() 16 | { 17 | _lastLineState = LineState(); 18 | _lastStateChangeTime = micros(); 19 | } 20 | 21 | void CEC_Electrical::SetAddress(int address) 22 | { 23 | _address = address & 0x0f; 24 | } 25 | 26 | bool CEC_Electrical::Raise() 27 | { 28 | if (MonitorMode) 29 | return LineState(); 30 | 31 | unsigned long time = micros(); 32 | SetLineState(1); 33 | // Only update state if the line was actually changed (i.e. it wasn't already in its new state) 34 | if (LineState()) 35 | { 36 | _lastLineState = true; 37 | _lastStateChangeTime = time; 38 | return true; 39 | } 40 | return false; 41 | } 42 | 43 | bool CEC_Electrical::Lower() 44 | { 45 | if (MonitorMode) 46 | return LineState(); 47 | 48 | unsigned long time = micros(); 49 | SetLineState(0); 50 | // Only update state if the line was actually changed (i.e. it wasn't already in its new state) 51 | if (!LineState()) 52 | { 53 | if (_lastLineState) 54 | _bitStartTime = time; 55 | _lastLineState = false; 56 | _lastStateChangeTime = time; 57 | return false; 58 | } 59 | return true; 60 | } 61 | 62 | void CEC_Electrical::HasRaised(unsigned long time) 63 | { 64 | _lastLineState = true; 65 | _lastStateChangeTime = time; 66 | } 67 | 68 | void CEC_Electrical::HasLowered(unsigned long time) 69 | { 70 | _lastLineState = false; 71 | _lastStateChangeTime = time; 72 | _bitStartTime = time; 73 | } 74 | 75 | bool CEC_Electrical::CheckAddress() 76 | { 77 | if (ReceivedBytes() == 1) 78 | { 79 | int address = _receiveBuffer[0] & 0x0f; 80 | if (address != _address && address != 0x0f) 81 | { 82 | // It's not addressed to us and it's not a broadcast. 83 | // Reset and wait for the next start bit 84 | return false; 85 | } 86 | // It is either addressed to this device or its a broadcast 87 | if (address == 0x0f) 88 | _broadcast = true; 89 | else 90 | _follower = true; 91 | } 92 | return true; 93 | } 94 | 95 | void CEC_Electrical::ReceivedBit(bool state) 96 | { 97 | if (_tertiaryState == CEC_RCV_BIT_EOM) 98 | { 99 | //DbgPrint("%p: Received eom %d\n", this, state?1:0); 100 | _eom = state; 101 | } 102 | else 103 | { 104 | //DbgPrint("%p: Received bit %d\n", this, state?1:0); 105 | if (state) 106 | PushReceiveBit(1); 107 | else 108 | PushReceiveBit(0); 109 | } 110 | } 111 | 112 | unsigned long CEC_Electrical::LineError() 113 | { 114 | DbgPrint("%p: Line Error!\n", this); 115 | if (_follower || _broadcast) 116 | { 117 | _secondaryState = CEC_RCV_LINEERROR; 118 | Lower(); 119 | return micros() + 3600; 120 | } 121 | return ResetState() ? micros() : (unsigned long)-1; 122 | } 123 | 124 | /// 125 | /// CEC_Electrical::Process implements our main state machine 126 | /// which includes all reading and writing of state including 127 | /// acknowledgements and arbitration 128 | /// 129 | 130 | unsigned long CEC_Electrical::Process() 131 | { 132 | // We are either called because of an INTerrupt in which case 133 | // state has changed or because of a poll (during write). 134 | 135 | bool currentLineState = LineState(); 136 | bool lastLineState = _lastLineState; 137 | unsigned long waitTime = -1; // INFINITE; (== wait until an external event has occurred) 138 | unsigned long time = micros(); 139 | 140 | //DbgPrint("%d %d %d\n", _primaryState, _secondaryState, _tertiaryState); 141 | // If the state hasn't changed and we're not in a transmit 142 | // state then this is spurrious. 143 | if( currentLineState == lastLineState && 144 | !(_primaryState == CEC_TRANSMIT || 145 | (_primaryState == CEC_RECEIVE && 146 | (_secondaryState == CEC_RCV_ACK_SENT || 147 | _secondaryState == CEC_RCV_LINEERROR)))) 148 | return waitTime; 149 | 150 | unsigned long lasttime = _lastStateChangeTime; 151 | unsigned long difftime = time - _bitStartTime; 152 | 153 | if( currentLineState != lastLineState ) 154 | { 155 | // Line state has changed, update our internal state 156 | if (currentLineState) 157 | HasRaised(time); 158 | else 159 | HasLowered(time); 160 | } 161 | 162 | switch (_primaryState) 163 | { 164 | case CEC_IDLE: 165 | // If a high to low transition occurs, then we must be 166 | // beginning a start bit 167 | if (lastLineState && !currentLineState) 168 | { 169 | _primaryState = CEC_RECEIVE; 170 | _secondaryState = CEC_RCV_STARTBIT1; 171 | _follower = false; 172 | _broadcast = false; 173 | _amLastTransmittor = false; 174 | break; 175 | } 176 | 177 | // Nothing to do until we have a need to transmit 178 | // or we detect the falling edge of the start bit 179 | break; 180 | 181 | case CEC_RECEIVE: 182 | switch (_secondaryState) 183 | { 184 | case CEC_RCV_STARTBIT1: 185 | // We're waiting for the rising edge of the start bit 186 | if (difftime >= 3500 && difftime <= 3900) 187 | { 188 | // We now need to wait for the next falling edge 189 | _secondaryState = CEC_RCV_STARTBIT2; 190 | break; 191 | } 192 | // Illegal state. Go back to CEC_IDLE to wait for a valid 193 | // start bit 194 | //DbgPrint("1: %ld %ld\n", difftime, micros()); 195 | waitTime = ResetState() ? micros() : (unsigned long)-1; 196 | break; 197 | 198 | case CEC_RCV_STARTBIT2: 199 | // This should be the falling edge of the start bit 200 | if (difftime >= 4300 && difftime <= 4700) 201 | { 202 | // We've fully received the start bit. Begin receiving 203 | // a data bit 204 | _secondaryState = CEC_RCV_DATABIT1; 205 | _tertiaryState = CEC_RCV_BIT0; 206 | break; 207 | } 208 | // Illegal state. Go back to CEC_IDLE to wait for a valid 209 | // start bit 210 | //DbgPrint("2: %ld %ld\n", difftime, micros()); 211 | waitTime = ResetState() ? micros() : (unsigned long)-1; 212 | break; 213 | 214 | case CEC_RCV_DATABIT1: 215 | // We've received the rising edge of the data bit 216 | if (difftime >= 400 && difftime <= 800) 217 | { 218 | // We're receiving bit '1' 219 | ReceivedBit(true); 220 | _secondaryState = CEC_RCV_DATABIT2; 221 | break; 222 | } 223 | else if (difftime >= 1300 && difftime <= 1700) 224 | { 225 | // We're receiving bit '0' 226 | ReceivedBit(false); 227 | _secondaryState = CEC_RCV_DATABIT2; 228 | break; 229 | } 230 | // Illegal state. Go back to CEC_IDLE to wait for a valid 231 | // start bit 232 | waitTime = LineError(); 233 | break; 234 | 235 | case CEC_RCV_DATABIT2: 236 | // We've received the falling edge of the data bit 237 | if (difftime >= 2050 && difftime <= 2750) 238 | { 239 | if (_tertiaryState == CEC_RCV_BIT_EOM) 240 | { 241 | _secondaryState = CEC_RCV_ACK1; 242 | _tertiaryState = (CEC_TERTIARY_STATE)(_tertiaryState + 1); 243 | 244 | // Check to see if the frame is addressed to us 245 | // or if we are in promiscuous mode (in which case we'll receive everything) 246 | if (!CheckAddress() && !Promiscuous) 247 | { 248 | // It's not addressed to us. Reset and wait for the next start bit 249 | waitTime = ResetState() ? micros() : (unsigned long)-1; 250 | break; 251 | } 252 | 253 | // If we're the follower, go low for a while 254 | if (_follower) 255 | { 256 | Lower(); 257 | 258 | _secondaryState = CEC_RCV_ACK_SENT; 259 | waitTime = _bitStartTime + 1500; 260 | } 261 | break; 262 | } 263 | // Receive another bit 264 | _secondaryState = CEC_RCV_DATABIT1; 265 | _tertiaryState = (CEC_TERTIARY_STATE)(_tertiaryState + 1); 266 | break; 267 | } 268 | // Illegal state. Go back to CEC_IDLE to wait for a valid 269 | // start bit 270 | waitTime = LineError(); 271 | break; 272 | 273 | case CEC_RCV_ACK_SENT: 274 | // We're done holding the line low... release it 275 | Raise(); 276 | if (_eom) 277 | { 278 | // We're not going to receive anything more from 279 | // the initiator (EOM has been received) 280 | // And we've sent the ACK for the most recent bit 281 | // therefore this message is all done. Go back 282 | // to the IDLE state and wait for another start bit. 283 | ProcessFrame(); 284 | waitTime = ResetState() ? micros() : (unsigned long)-1; 285 | break; 286 | } 287 | // We need to wait for the falling edge of the ACK 288 | // to finish processing this ack 289 | _secondaryState = CEC_RCV_ACK2; 290 | _tertiaryState = CEC_ACK; 291 | break; 292 | 293 | // FIXME: This is dead state 294 | // Code currently exists in CEC_RCV_DATABIT2 that checks the address 295 | // of the frame and if it isn't addressed to this device it goes back 296 | // to watching for a start bit state. This state, CEC_RCV_ACK1, was 297 | // from when we didn't do that and we followed state for all frames 298 | // regardless of addressing. However, I'm not removing this code because 299 | // it will be needed when we support broadcast frames. 300 | case CEC_RCV_ACK1: 301 | { 302 | int ack; 303 | if (difftime >= 400 && difftime <= 800) 304 | ack = _broadcast ? CEC_ACK : CEC_NAK; 305 | else if (difftime >= 1300 && difftime <= 1700) 306 | ack = _broadcast ? CEC_NAK : CEC_ACK; 307 | else 308 | { 309 | // Illegal state. Go back to CEC_IDLE to wait for a valid 310 | // start bit 311 | waitTime = LineError(); 312 | break; 313 | } 314 | 315 | if (_eom && ack == CEC_ACK) 316 | { 317 | // We're not going to receive anything more from 318 | // the initiator (EOM has been received) 319 | // And we've seen the ACK for the most recent bit 320 | // therefore this message is all done. Go back 321 | // to the IDLE state and wait for another start bit. 322 | ProcessFrame(); 323 | waitTime = ResetState() ? micros() : (unsigned long)-1; 324 | break; 325 | } 326 | if (ack == CEC_NAK) 327 | { 328 | waitTime = ResetState() ? micros() : (unsigned long)-1; 329 | break; 330 | } 331 | 332 | // receive the rest of the ACK (or rather the beginning of the next bit) 333 | _secondaryState = CEC_RCV_ACK2; 334 | break; 335 | } 336 | 337 | case CEC_RCV_ACK2: 338 | // We're receiving the falling edge of the ack 339 | if (difftime >= 2050 && difftime <= 2750) 340 | { 341 | _secondaryState = CEC_RCV_DATABIT1; 342 | _tertiaryState = CEC_RCV_BIT0; 343 | break; 344 | } 345 | // Illegal state (or NACK). Either way, go back to CEC_IDLE 346 | // to wait for next start bit (maybe a retransmit).. 347 | waitTime = LineError(); 348 | break; 349 | 350 | case CEC_RCV_LINEERROR: 351 | //DbgPrint("%p: Done signaling line error\n", this); 352 | Raise(); 353 | waitTime = ResetState() ? micros() : (unsigned long)-1; 354 | break; 355 | 356 | } 357 | 358 | break; 359 | 360 | case CEC_TRANSMIT: 361 | if (lastLineState != currentLineState) 362 | { 363 | // Someone else is mucking with the line. Wait for the 364 | // line to clear before appropriately before (re)transmit 365 | 366 | // However it is OK for a follower to ACK if we are in an 367 | // ACK state 368 | if (_secondaryState != CEC_XMIT_ACK && 369 | _secondaryState != CEC_XMIT_ACK2 && 370 | _secondaryState != CEC_XMIT_ACK3 && 371 | _secondaryState != CEC_XMIT_ACK_TEST) 372 | { 373 | // If a state changed TO LOW during IDLE wait, someone could be legitimately transmitting 374 | if (_secondaryState == CEC_IDLE_WAIT) 375 | { 376 | if (currentLineState == false) 377 | { 378 | _primaryState = CEC_RECEIVE; 379 | _secondaryState = CEC_RCV_STARTBIT1; 380 | _transmitPending = true; 381 | } 382 | break; 383 | } 384 | else 385 | { 386 | // Transmit collision 387 | ResetTransmit(true); 388 | waitTime = 0; 389 | break; 390 | } 391 | } 392 | else 393 | { 394 | // This is a state change from an ACK and isn't part of our state 395 | // tracking. 396 | waitTime = -2; 397 | break; 398 | } 399 | } 400 | 401 | unsigned long neededIdleTime = 0; 402 | switch (_secondaryState) 403 | { 404 | case CEC_IDLE_WAIT: 405 | // We need to wait a certain amount of time before we can 406 | // transmit.. 407 | 408 | // If the line is low, we can't do anything now. Wait 409 | // indefinitely until a line state changes which will 410 | // catch in the code just above 411 | if (currentLineState == 0) 412 | break; 413 | 414 | // The line is high. Have we waited long enough? 415 | neededIdleTime = 0; 416 | switch (_tertiaryState) 417 | { 418 | case CEC_IDLE_RETRANSMIT_FRAME: 419 | neededIdleTime = 3 * 2400; 420 | break; 421 | 422 | case CEC_IDLE_NEW_FRAME: 423 | neededIdleTime = 5 * 2400; 424 | break; 425 | 426 | case CEC_IDLE_SUBSEQUENT_FRAME: 427 | neededIdleTime = 7 * 2400; 428 | break; 429 | } 430 | 431 | if (time - _lastStateChangeTime < neededIdleTime) 432 | { 433 | // not waited long enough, wait some more! 434 | waitTime = lasttime + neededIdleTime; 435 | break; 436 | } 437 | 438 | // we've wait long enough, begin start bit 439 | Lower(); 440 | _amLastTransmittor = true; 441 | _broadcast = (_transmitBuffer[0] & 0x0f) == 0x0f; 442 | 443 | // wait 3700 microsec 444 | waitTime = _bitStartTime + 3700; 445 | 446 | // and transition to our next state 447 | _secondaryState = CEC_XMIT_STARTBIT1; 448 | break; 449 | 450 | case CEC_XMIT_STARTBIT1: 451 | if (!Raise()) 452 | { 453 | //DbgPrint("%p: Received Line Error\n", this); 454 | ResetTransmit(true); 455 | break; 456 | } 457 | 458 | waitTime = _bitStartTime + 4500; 459 | _secondaryState = CEC_XMIT_STARTBIT2; 460 | break; 461 | 462 | case CEC_XMIT_STARTBIT2: 463 | case CEC_XMIT_ACK3: 464 | Lower(); 465 | 466 | _secondaryState = CEC_XMIT_DATABIT1; 467 | _tertiaryState = CEC_XMIT_BIT0; 468 | 469 | if (PopTransmitBit()) 470 | { 471 | // Sending bit '1' 472 | //DbgPrint("%p: Sending bit 1\n", this); 473 | waitTime = _bitStartTime + 600; 474 | } 475 | else 476 | { 477 | // Sending bit '0' 478 | //DbgPrint("%p: Sending bit 0\n", this); 479 | waitTime = _bitStartTime + 1500; 480 | } 481 | break; 482 | 483 | case CEC_XMIT_DATABIT1: 484 | if (!Raise()) 485 | { 486 | //DbgPrint("%p: Received Line Error\n", this); 487 | ResetTransmit(true); 488 | break; 489 | } 490 | 491 | waitTime = _bitStartTime + 2400; 492 | 493 | if (_tertiaryState == CEC_XMIT_BIT_EOM) 494 | { 495 | // We've just finished transmitting the EOM 496 | // move on to the ACK 497 | _secondaryState = CEC_XMIT_ACK; 498 | } 499 | else 500 | _secondaryState = CEC_XMIT_DATABIT2; 501 | break; 502 | 503 | case CEC_XMIT_DATABIT2: 504 | Lower(); 505 | 506 | _tertiaryState = (CEC_TERTIARY_STATE)(_tertiaryState + 1); 507 | 508 | if (_tertiaryState == CEC_XMIT_BIT_EOM) 509 | { 510 | if (RemainingTransmitBytes() == 0) 511 | { 512 | // Sending eom '1' 513 | //DbgPrint("%p: Sending eom 1\n", this); 514 | waitTime = _bitStartTime + 600; 515 | } 516 | else 517 | { 518 | // Sending eom '0' 519 | //DbgPrint("%p: Sending eom 0\n", this); 520 | waitTime = _bitStartTime + 1500; 521 | } 522 | } 523 | else 524 | { 525 | if (PopTransmitBit()) 526 | { 527 | // Sending bit '1' 528 | //DbgPrint("%p: Sending bit 1\n", this); 529 | waitTime = _bitStartTime + 600; 530 | } 531 | else 532 | { 533 | // Sending bit '0' 534 | //DbgPrint("%p: Sending bit 0\n", this); 535 | waitTime = _bitStartTime + 1500; 536 | } 537 | } 538 | _secondaryState = CEC_XMIT_DATABIT1; 539 | break; 540 | 541 | case CEC_XMIT_ACK: 542 | Lower(); 543 | 544 | // We transmit a '1' 545 | //DbgPrint("%p: Sending ack\n", this); 546 | waitTime = _bitStartTime + 600; 547 | _secondaryState = CEC_XMIT_ACK2; 548 | break; 549 | 550 | case CEC_XMIT_ACK2: 551 | Raise(); 552 | 553 | // we need to sample the state in a little bit 554 | waitTime = _bitStartTime + 1050; 555 | _secondaryState = CEC_XMIT_ACK_TEST; 556 | break; 557 | 558 | case CEC_XMIT_ACK_TEST: 559 | //DbgPrint("%p: Testing ack: %d\n", this, (currentLineState == 0) != _broadcast?1:0); 560 | if ((currentLineState != 0) != _broadcast) 561 | { 562 | // not being acknowledged 563 | // normally we retransmit. But this is NOT the case for as its 564 | // function is basically to 'ping' a logical address in which case we just want 565 | // acknowledgement that it has succeeded or failed 566 | if (RemainingTransmitBytes() == 0 && TransmitSize() == 1) 567 | { 568 | ResetState(); 569 | DbgPrint("Transmit failed, no acknowledge.\n"); 570 | OnTransmitComplete(false); 571 | } 572 | else 573 | { 574 | ResetTransmit(true); 575 | waitTime = 0; 576 | } 577 | break; 578 | } 579 | 580 | _lastStateChangeTime = lasttime; 581 | 582 | if (RemainingTransmitBytes() == 0) 583 | { 584 | // Nothing left to transmit, go back to idle 585 | ResetState(); 586 | OnTransmitComplete(true); 587 | break; 588 | } 589 | 590 | // We have more to transmit, so do so... 591 | waitTime = _bitStartTime + 2400; 592 | _secondaryState = CEC_XMIT_ACK3; 593 | break; 594 | } 595 | } 596 | return waitTime; 597 | } 598 | 599 | bool CEC_Electrical::ResetState() 600 | { 601 | _primaryState = CEC_IDLE; 602 | _secondaryState = (CEC_SECONDARY_STATE)0; 603 | _tertiaryState = (CEC_TERTIARY_STATE)0; 604 | _eom = false; 605 | _follower = false; 606 | _broadcast = false; 607 | ResetReceiveBuffer(); 608 | 609 | if (_transmitPending) 610 | { 611 | ResetTransmit(false); 612 | return true; 613 | } 614 | return false; 615 | } 616 | 617 | void CEC_Electrical::ResetTransmit(bool retransmit) 618 | { 619 | _primaryState = CEC_TRANSMIT; 620 | _secondaryState = CEC_IDLE_WAIT; 621 | _tertiaryState = CEC_IDLE_NEW_FRAME; 622 | _transmitPending = false; 623 | 624 | if (retransmit) 625 | { 626 | if (++_xmitretry == CEC_MAX_RETRANSMIT) 627 | { 628 | // No more 629 | ResetState(); 630 | DbgPrint("Transmit failed, max retries reached.\n"); 631 | OnTransmitComplete(false); 632 | } 633 | else 634 | { 635 | //DbgPrint("%p: Retransmitting current frame\n", this); 636 | _tertiaryState = CEC_IDLE_RETRANSMIT_FRAME; 637 | ResetTransmitBuffer(); 638 | } 639 | } 640 | else 641 | { 642 | _xmitretry = 0; 643 | if (_amLastTransmittor) 644 | { 645 | _tertiaryState = CEC_IDLE_SUBSEQUENT_FRAME; 646 | } 647 | } 648 | } 649 | 650 | void CEC_Electrical::ProcessFrame() 651 | { 652 | // We've successfully received a frame in the serial line buffer 653 | // Allow it to be processed 654 | OnReceiveComplete(_receiveBuffer, _receiveBufferByte); 655 | } 656 | 657 | void CEC_Electrical::OnTransmitBegin() 658 | { 659 | if (!MonitorMode) 660 | { 661 | if (_primaryState == CEC_IDLE) 662 | { 663 | ResetTransmit(false); 664 | return; 665 | } 666 | _transmitPending = true; 667 | } 668 | } 669 | 670 | void CEC_Electrical::OnTransmitComplete(bool success) 671 | { 672 | } 673 | -------------------------------------------------------------------------------- /extras/CEC_keylist.fods: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Florian Echtler2016-02-01T08:53:32.4285869232016-02-05T09:31:35.829572178Florian EchtlerPT5M7S4LibreOffice/4.2.8.2$Linux_X86_64 LibreOffice_project/420m0$Build-2 5 | 6 | 7 | 0 8 | 0 9 | 9181 10 | 36576 11 | 12 | 13 | view1 14 | 15 | 16 | 2 17 | 1 18 | 0 19 | 0 20 | 0 21 | 0 22 | 2 23 | 0 24 | 0 25 | 0 26 | 0 27 | 0 28 | 100 29 | 60 30 | true 31 | 32 | 33 | Tabelle1 34 | 270 35 | 0 36 | 100 37 | 60 38 | false 39 | true 40 | true 41 | true 42 | 12632256 43 | true 44 | true 45 | true 46 | true 47 | false 48 | false 49 | 1000 50 | 1000 51 | 1 52 | 1 53 | true 54 | 55 | 56 | 57 | 58 | false 59 | false 60 | false 61 | false 62 | true 63 | 0 64 | lAH+/0NvbG9yTGFzZXJqZXRDUDUyMjVkbgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ1VQUzpDb2xvckxhc2VyamV0Q1A1MjI1ZG4AAAAAAAAWAAMAugAAAAAAAAAEAAhSAAAEdAAASm9iRGF0YSAxCnByaW50ZXI9Q29sb3JMYXNlcmpldENQNTIyNWRuCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCmNvbGxhdGU9ZmFsc2UKbWFyZ2luZGFqdXN0bWVudD0wLDAsMCwwCmNvbG9yZGVwdGg9MjQKcHNsZXZlbD0wCnBkZmRldmljZT0xCmNvbG9yZGV2aWNlPTAKUFBEQ29udGV4RGF0YQpQYWdlU2l6ZTpBNAAAEgBDT01QQVRfRFVQTEVYX01PREUKAERVUExFWF9PRkY= 65 | ColorLaserjetCP5225dn 66 | true 67 | true 68 | false 69 | false 70 | false 71 | 1 72 | true 73 | true 74 | 1000 75 | true 76 | 3 77 | true 78 | true 79 | true 80 | 12632256 81 | true 82 | 1 83 | 1000 84 | true 85 | true 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | - 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | ??? 178 | 179 | 180 | 181 | Seite 1 182 | 183 | 184 | 185 | 186 | 187 | 188 | ??? (???) 189 | 190 | 191 | 00.00.0000, 00:00:00 192 | 193 | 194 | 195 | 196 | Seite 1 / 99 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | raw CEC ID 210 | 211 | 212 | CEC Name 213 | 214 | 215 | Linux Name 216 | 217 | 218 | 219 | 220 | 0x00 221 | 222 | 223 | Select 224 | 225 | 226 | KEY_ENTER 227 | 228 | 229 | 230 | 231 | 0x01 232 | 233 | 234 | Up 235 | 236 | 237 | KEY_UP 238 | 239 | 240 | 241 | 242 | 0x02 243 | 244 | 245 | Down 246 | 247 | 248 | KEY_DOWN 249 | 250 | 251 | 252 | 253 | 0x03 254 | 255 | 256 | Left 257 | 258 | 259 | KEY_LEFT 260 | 261 | 262 | 263 | 264 | 0x04 265 | 266 | 267 | Right 268 | 269 | 270 | KEY_RIGHT 271 | 272 | 273 | 274 | 275 | 0x05 276 | 277 | 278 | Right-Up 279 | 280 | 281 | 282 | 283 | 284 | 0x06 285 | 286 | 287 | Right-Down 288 | 289 | 290 | 291 | 292 | 293 | 0x07 294 | 295 | 296 | Left-Up 297 | 298 | 299 | 300 | 301 | 302 | 0x08 303 | 304 | 305 | Left-Down 306 | 307 | 308 | 309 | 310 | 311 | 0x09 312 | 313 | 314 | Root Menu – see Note 2 315 | 316 | 317 | KEY_HOME 318 | 319 | 320 | 321 | 322 | 0x0A 323 | 324 | 325 | Setup Menu 326 | 327 | 328 | 329 | 330 | 331 | 0x0B 332 | 333 | 334 | Contents Menu 335 | 336 | 337 | KEY_MEDIA 338 | 339 | 340 | 341 | 342 | 0x0C 343 | 344 | 345 | Favorite Menu 346 | 347 | 348 | 349 | 350 | 351 | 0x0D 352 | 353 | 354 | Exit 355 | 356 | 357 | KEY_ESC 358 | 359 | 360 | 361 | 362 | 0x0E - 0x1F 363 | 364 | 365 | Reserved 366 | 367 | 368 | 369 | 370 | 371 | 0x20 - 0x29 372 | 373 | 374 | Numbers 0-9 375 | 376 | 377 | KEY_0 – KEY_9 378 | 379 | 380 | 381 | 382 | 0x2A 383 | 384 | 385 | Dot 386 | 387 | 388 | KEY_DOT 389 | 390 | 391 | 392 | 393 | 0x2B 394 | 395 | 396 | Enter 397 | 398 | 399 | KEY_ENTER 400 | 401 | 402 | 403 | 404 | 0x2C 405 | 406 | 407 | Clear 408 | 409 | 410 | KEY_BACKSPACE 411 | 412 | 413 | 414 | 415 | 0x2D - 0x2E 416 | 417 | 418 | Reserved 419 | 420 | 421 | 422 | 423 | 424 | 0x2F 425 | 426 | 427 | Next Favorite 428 | 429 | 430 | 431 | 432 | 433 | 0x30 434 | 435 | 436 | Channel Up 437 | 438 | 439 | 440 | 441 | 442 | 0x31 443 | 444 | 445 | Channel Down 446 | 447 | 448 | 449 | 450 | 451 | 0x32 452 | 453 | 454 | Previous Channel 455 | 456 | 457 | 458 | 459 | 460 | 0x33 461 | 462 | 463 | Sound Select 464 | 465 | 466 | 467 | 468 | 469 | 0x34 470 | 471 | 472 | Input Select 473 | 474 | 475 | 476 | 477 | 478 | 0x35 479 | 480 | 481 | Display Information 482 | 483 | 484 | 485 | 486 | 487 | 0x36 488 | 489 | 490 | Help 491 | 492 | 493 | KEY_QUESTION 494 | 495 | 496 | 497 | 498 | 0x37 499 | 500 | 501 | Page Up 502 | 503 | 504 | KEY_PAGEUP 505 | 506 | 507 | 508 | 509 | 0x38 510 | 511 | 512 | Page Down 513 | 514 | 515 | 516 | 517 | 518 | 0x39 - 0x3F 519 | 520 | 521 | Reserved 522 | 523 | 524 | 525 | 526 | 527 | 0x40 528 | 529 | 530 | Power 531 | 532 | 533 | 534 | 535 | 536 | 0x41 537 | 538 | 539 | Volume Up 540 | 541 | 542 | 543 | 544 | 545 | 0x42 546 | 547 | 548 | Volume Down 549 | 550 | 551 | 552 | 553 | 554 | 0x43 555 | 556 | 557 | Mute 558 | 559 | 560 | 561 | 562 | 563 | 0x44 564 | 565 | 566 | Play 567 | 568 | 569 | 570 | 571 | 572 | 0x45 573 | 574 | 575 | Stop 576 | 577 | 578 | 579 | 580 | 581 | 0x46 582 | 583 | 584 | Pause 585 | 586 | 587 | 588 | 589 | 590 | 0x47 591 | 592 | 593 | Record 594 | 595 | 596 | 597 | 598 | 599 | 0x48 600 | 601 | 602 | Rewind 603 | 604 | 605 | 606 | 607 | 608 | 0x49 609 | 610 | 611 | Fast forward 612 | 613 | 614 | 615 | 616 | 617 | 0x4A 618 | 619 | 620 | Eject 621 | 622 | 623 | 624 | 625 | 626 | 0x4B 627 | 628 | 629 | Forward 630 | 631 | 632 | 633 | 634 | 635 | 0x4C 636 | 637 | 638 | Backward 639 | 640 | 641 | 642 | 643 | 644 | 0x4D 645 | 646 | 647 | Stop-Record 648 | 649 | 650 | 651 | 652 | 653 | 0x4E 654 | 655 | 656 | Pause-Record 657 | 658 | 659 | 660 | 661 | 662 | 0x4F 663 | 664 | 665 | Reserved 666 | 667 | 668 | 669 | 670 | 671 | 0x50 672 | 673 | 674 | Angle 675 | 676 | 677 | 678 | 679 | 680 | 0x51 681 | 682 | 683 | Sub picture 684 | 685 | 686 | 687 | 688 | 689 | 0x52 690 | 691 | 692 | Video on Demand 693 | 694 | 695 | 696 | 697 | 698 | 0x53 699 | 700 | 701 | Electronic Program Guide 702 | 703 | 704 | 705 | 706 | 707 | 0x54 708 | 709 | 710 | Timer Programming 711 | 712 | 713 | 714 | 715 | 716 | 0x55 717 | 718 | 719 | Initial Configuration 720 | 721 | 722 | 723 | 724 | 725 | 0x56 - 0x5F 726 | 727 | 728 | Reserved 729 | 730 | 731 | 732 | 733 | 734 | 0x60 735 | 736 | 737 | Play Function 738 | 739 | 740 | 741 | 742 | 743 | 0x61 744 | 745 | 746 | Pause-Play Function 747 | 748 | 749 | 750 | 751 | 752 | 0x62 753 | 754 | 755 | Record Function 756 | 757 | 758 | 759 | 760 | 761 | 0x63 762 | 763 | 764 | Pause-Record Function 765 | 766 | 767 | 768 | 769 | 770 | 0x64 771 | 772 | 773 | Stop Function 774 | 775 | 776 | 777 | 778 | 779 | 0x65 780 | 781 | 782 | Mute Function 783 | 784 | 785 | 786 | 787 | 788 | 0x66 789 | 790 | 791 | Restore Volume Function 792 | 793 | 794 | 795 | 796 | 797 | 0x67 798 | 799 | 800 | Tune Function 801 | 802 | 803 | 804 | 805 | 806 | 0x68 807 | 808 | 809 | Select Media Function 810 | 811 | 812 | 813 | 814 | 815 | 0x69 816 | 817 | 818 | Select A/V Input Function 819 | 820 | 821 | 822 | 823 | 824 | 0x6A 825 | 826 | 827 | Select Audio Input Function 828 | 829 | 830 | 831 | 832 | 833 | 0x6B 834 | 835 | 836 | Power Toggle Function 837 | 838 | 839 | 840 | 841 | 842 | 0x6C 843 | 844 | 845 | Power Off Function 846 | 847 | 848 | 849 | 850 | 851 | 0x6D 852 | 853 | 854 | Power On Function 855 | 856 | 857 | 858 | 859 | 860 | 0x6E – 0x70 861 | 862 | 863 | Reserved 864 | 865 | 866 | 867 | 868 | 869 | 0x71 870 | 871 | 872 | F1 (Blue) 873 | 874 | 875 | 876 | 877 | 878 | 0x72 879 | 880 | 881 | F2 (Red) 882 | 883 | 884 | 885 | 886 | 887 | 0x73 888 | 889 | 890 | F3 (Green) 891 | 892 | 893 | 894 | 895 | 896 | 0x74 897 | 898 | 899 | F4 (Yellow) 900 | 901 | 902 | 903 | 904 | 905 | 0x75 906 | 907 | 908 | F5 909 | 910 | 911 | 912 | 913 | 914 | 0x76 915 | 916 | 917 | Data – see Note 3 918 | 919 | 920 | 921 | 922 | 923 | 0x77 – 0xFF 924 | 925 | 926 | Reserved 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | Note 2: This is the initial display that a device shows. It is device-dependent and can be, for example, a contents menu, setup menu, favorite menu 936 | 937 | 938 | 939 | 940 | 941 | 942 | or other menu. The actual menu displayed may also depend on the device’s current state. 943 | 944 | 945 | 946 | 947 | 948 | Note 3: This is used, for example, to enter or leave a digital TV data broadcast application. 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | --------------------------------------------------------------------------------