Set Active Port on a Controller

The active port is needed to be able to communicate with a downstream or peripheral. To set the active port we need to look at communication port definitions for the controller. There should only be one internal port, at least for the controller in our example (EP1501), so we will find that port and then set it to active.

For more information on Communication Ports and the methods used please look at CommunicationPortDefinitionItem.

Example in C#

var ports = await client.GetCommunicationPortDefinitionsAsync(controller);
var port = ports.Single(p => p.IsInternal);
await client.SetActivePortAsync(controller, new ActivePortItem
    { DriverNumber = port.DriverNumber});

Example in CURL

curl -X PUT \
  https://keepapi.feenicshosting.com/api/f/INSTANCE.KEY/controllers/CONTROLLER.KEY/activeports \
  -H 'Authorization:  Bearer TOKEN_GOES_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
        "$type":"Feenics.Keep.WebApi.Model.ActivePortItem, Feenics.Keep.WebApi.Model",
        "DriverNumber":0,
        "BaudRate":0
     }'