User manual

8Page
Velleman Projects
3.1
Open Devices
Syntax
int OpenDevices();
Result
int: If succeeded the return value will indicate the number of VM167 cards found.
1: Card in the Card Address 0 found.
2: Card in the Card Address 1 found.
3: Card in the Card Address 0 and 1 found.
Return value -1 indicates that no VM167 cards found.
Return value 0 indicates that there was problems to open the driver. Disconnect and reconnect the
USB cable.
Description
Opens the communication link to the VM167 card. Loads the drivers needed to communicate via the
USB port. This procedure must be performed before any attempts to communicate with the VM167
cards.
Example
int Cards;
...
Cards = OpenDevices();
switch (Cards)
{
case 0:
Label1->Text = "Card open error.";
break;
case 1:
Label1->Text = "Card 0 connected.";
RadioButton1->Enabled = true;
RadioButton1->Checked = true;
CardAddress = 0;
Timer1->Enabled = true;
break;
case 2:
Label1->Text = "Card 1 connected.";
RadioButton2->Enabled = true;
RadioButton2->Checked = true;
CardAddress = 1;
Timer1->Enabled = true;
break;
case 3:
Label1->Text = "Cards 0 and 1 connected.";
RadioButton1->Enabled = true;
RadioButton1->Checked = true;
RadioButton2->Enabled = true;
RadioButton2->Checked = false;
CardAddress = 0;
Timer1->Enabled = true;
break;
case -1:
Label1->Text = "Card not found.";
break;
}