Ps2KeyboardHost  1.0.1
Allows you to read from one or more PS2-style keyboards on an Arduino.
ps2_NullDiagnostics.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Steve Benz <s8878992@hotmail.com>
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 USA
18 */
19 #pragma once
20 #include <stdint.h>
21 #include "ps2_KeyboardLeds.h"
22 #include "ps2_KeyboardOutput.h"
23 
24 namespace ps2 {
25 
34  public:
35  // These usually mean an interrupt got dropped - e.g. because another interrupt
36  // or critical operation was happening when the clock pin dropped.
38  void parityError() {}
40  void packetIncomplete() {}
41  void sendFrameError() {}
42  void startupFailure() {}
43 
44  // Polling frequency isn't high enough or the buffer is too small.
45  void bufferOverflow() {}
46 
47  // This would probably mean a bug in the implementation of the protocol.
48  void incorrectResponse(ps2::KeyboardOutput scanCode, ps2::KeyboardOutput expectedScanCode) {}
49  void noResponse(ps2::KeyboardOutput expectedScanCode) {}
50 
51  // Translator errors
52  void noTranslationForKey(bool isExtended, KeyboardOutput code) {}
53 
54  //-------------------------------------------------------------------------------
55  // Above this line are errors, below it are normal events (or possibly events that
56  // are recovery from errors).
57 
58  void sentByte(byte b) {}
59  void receivedByte(byte b) {}
60  void clockLineGlitch(uint8_t numBitsSent) {}
61 
62  // Only the Null class should provide this interface. Note that this implementation
63  // returns something bogus, which is only okay because all of the implementations are empty,
64  // and get optimized away by the compiler.
65  static NullDiagnostics *defaultInstance() { return (NullDiagnostics *)nullptr; }
66  };
67 }
void noResponse(ps2::KeyboardOutput expectedScanCode)
Definition: ps2_NullDiagnostics.h:49
void packetDidNotEndWithOne()
Definition: ps2_NullDiagnostics.h:39
void parityError()
Definition: ps2_NullDiagnostics.h:38
void incorrectResponse(ps2::KeyboardOutput scanCode, ps2::KeyboardOutput expectedScanCode)
Definition: ps2_NullDiagnostics.h:48
Definition: ps2_AnsiTranslator.h:24
void noTranslationForKey(bool isExtended, KeyboardOutput code)
Definition: ps2_NullDiagnostics.h:52
void sendFrameError()
Definition: ps2_NullDiagnostics.h:41
void packetDidNotStartWithZero()
Definition: ps2_NullDiagnostics.h:37
void receivedByte(byte b)
Definition: ps2_NullDiagnostics.h:59
This is the default class for diagnostic information for all the classes in this library. It&#39;s the class you want if want to drop diagnostic information on the floor (because, say, your device works plenty reliably and there&#39;s nothing to debug anymore). If you&#39;re not in that blessed place, then you can create your own class that implements all these methods and stashes the data somewhere.
Definition: ps2_NullDiagnostics.h:33
void clockLineGlitch(uint8_t numBitsSent)
Definition: ps2_NullDiagnostics.h:60
KeyboardOutput
Byte-codes sent back from the Ps2 keyboard to the host.
Definition: ps2_KeyboardOutput.h:31
void sentByte(byte b)
Definition: ps2_NullDiagnostics.h:58
void packetIncomplete()
Definition: ps2_NullDiagnostics.h:40
static NullDiagnostics * defaultInstance()
Definition: ps2_NullDiagnostics.h:65
void startupFailure()
Definition: ps2_NullDiagnostics.h:42
void bufferOverflow()
Definition: ps2_NullDiagnostics.h:45