PHP code example of volantus / msp-protocol

1. Go to this page and download the library: Download volantus/msp-protocol library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

volantus / msp-protocol example snippets


    use Volantus\MSPProtocol\Src\Protocol\CommunicationService;
    use Volantus\MSPProtocol\Src\Protocol\Request\MotorStatus as MotorStatusRequest;
    use Volantus\MSPProtocol\Src\Protocol\Response\MotorStatus as MotorStatusResponse;
    use Volantus\MSPProtocol\Src\Serial\SerialInterface;
    
    $serialInterface = new SerialInterface('/dev/ttyUSB0', 115200);
    $service = new CommunicationService($serialInterface);
    
    /** @var MotorStatusResponse $response */
    $response = $service->send(new MotorStatusRequest());
    
    // Status of the first motor (Value between 1000 and 2000)
    $response->getStatuses()[0];