A few PHP classes to talk to GPIB capable devices through the Prologix GPIB interface. Currently, just the Prologix GPIB ETH interface is implemented. A work in progress.
#Usage
There are two ways to talk to devices connected to the GPIB bus. The first, using the send method, will send any command passed as an argument directly to the device. The second way is to use the addCommand method along with sendAll to store multiple commands and set them at once. send and sendAll accept an extra parameter, a GPIB address, which will prepend the ++addr command. Though it may be what you are looking for, keep in mind that this interface has a EEPROM in where some of the commands are saved (such as ++addr, ++mode, ++eot_char, etc) and prepending ++addr repeatedly will reduce it's lifespan. If you don't add this extra parameter, the commands will be sent to the currently addressed device. Additionally, you'll find some built in methods for common Prologix getters/setters. This methods accept an array of options (value and address). Without arguments, they will act as getters. The following examples achieve the same functionality:
$interface = new PrologixEth('192.168.254.243');
$interface->send('++addr6')
->send('CF70000000')
->send('SP1000000')
->send('RL-55');
$interface->address(['value' => 6])
->send('CF70000000')
->send('SP1000000')
->send('RL-55');
$interface->send('CF70000000', 6)
->send('SP1000000')
->send('RL-55');
$interface->addCommand('CF70000000')
->addCommand('SP1000000')
->addCommand('RL-55')
->sendAll(6);
This is how you get the current address value:
var_dump($interface->address());
And you may also set auto parameter as 0 and device with address #6 as listener
$interface->auto(['value' => 0, 'address' => 6])
You'll also find two examples for a HP8593E spectrum analyzer (though should work with most SA) and a HP3488A switch unit. Just two wrapper around the GpibInterface implemented by PrologixEth class with easy to remember methods for common tasks.
$spectrum = new HP8593E(6, $interface);
$spectrum->span(1000)
->centerFrecuency(70, ['unit' => 'mhz'])
->referenceLevel(-55)
->set();
Most of the methods will accept a value and an array of options. By default, this options are:
- unit => hz
- store => true
With store = true, the commands will be saved and you should manually send them to the device using the set method.
####TODO
- Prologix USB implementation (don't own one).
- Laravel related files (service providers, facades, config, etc).
- Find a better (**ANY**) socket implementation.
- Tests.