Public. Whether to drop the first zero from hex output.
If true, the methods which query the device's status do not prepend a zero for values lower than 0F, if the result is hexadecimal. If false, a two-character string is returned unconditionally. If $decimalOutput is set, the result of all query methods is a PHP integer regardless of this property.
If $dev is set, it calls setDev(); otherwise it does nothing. You might want it to do nothing if you want to set properties used by setDev() and other downstream methods before really initialising the object.
Each bit in the result represents a relay (the least significant bit represents the first relay, the most significant bit represents the last relay). A bit set to 1 means the relay is activated, a bit set to 0 means that it isn't.
the current status of the relays, or false on error.
This is called automatically by initDev(), you really shouldn't ever need to call it directly.
This class uses the phpSerial class to connect to the serial port in order to communicate with the device. Depending on your setup, you might want to tell this class where phpSerial resides (see $serialIncludePath and $serialIncludeFull), and what it's called (maybe you needed to rename the phpSerial class for some reason -- see $serialClassName).
Public. This is the lowest-level method for writing to the device within the context of this class.
In most circumstances you probably want to use sendOrder() instead of this method. Another alternative is the read()/write() combination.
Use this method in tandem with rawRead() if you want to handle all input and output from the device manually. The only pieces of logic these methods implement are the following:
The class sanity is verified before any attempt to communicate
with the device (i.e. the methods will not blindly attempt to
communicate if the serial device hasn't been defined or successfully
Method rawWrite() appends $kitEOL at the end of the command
so you don't have to append it every time.
Apart from those, you're on your own -- you have to process device echo, prompts, the whole deal.
Public. Send an order to the device and retrieve the output.
This is the highest-level method in the context of this class except the truly dedicated methods like setRelays(), getRelays(), etc.
This method uses write() and rawRead() to handle all I/O strings related to a Kit108 unit -- it processes the EOLs, the device prompt, echo and so on; it interprets the type of command it has been issued in the context of a Kit108 unit (it decides whether it was given a command or it was asked to provide the result of a query) and acts accordingly.
the device's response in case of a query, boolean true if a command has been successfully passed to the device, or boolean false on failure
Public. Sets all relays to the values passed in $relays.
The device has eight relays, and there are eight bits in a byte. This method takes a value between 0 and 255 and sets all eight relays according to on and off depending on whether the bits in the input value are set (relay ON) or not set (relay OFF).
Passing values below 0 or above 255 will result in an error.
Both read() and write() are relatively low-level methods within the context of this class, you typically don't need to call them directly. In most contexts, you probably want to call sendOrder() instead.
On the other hand, these methods still perform some logic of their own within the context of this class, and read() attempts to clean up the output. If you want to go down and dirty and process all I/O manually, use rawRead() and rawWrite() instead.
As opposed to sendOrder(), this method only writes the order to the serial device, without waiting for or processing the output -- you will need to call read() afterwards to retrieve the output.
Private. Decides whether this class will ever work on this system.
This is where $neverWork is set (or not). The decision is based on the operating system you're using. Currently only Linux is fully supported. You can override the default behavior by setting constant KIT108_OVERRIDE_OS to boolean true (strict). For more details, see this page.