Commit b093ebb6 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add serial number check

parent 00e102f8
blocks {
{ "ec", "ethercat", "eth0", 3, 0 }
{ "stoeber", "dt_az", 2, 10, 100, 60 }
{ "stoeber", "dt_az", 2, 0, 10.0, 100.0, 60.0 }
}
blocks {
{ "ec", "ethercat", "eth0", 3, 0 }
{ "stoeber", "dt_el_r", 0, 1, 200, 40 }
{ "stoeber", "dt_el_l", 1, 1, 200, 40 }
{ "stoeber", "dt_el_r", 0, 0, 1.0, 200.0, 40.0 }
{ "stoeber", "dt_el_l", 1, 0, 1.0, 200.0, 40.0 }
}
......@@ -205,9 +205,11 @@ struct controller_block *block_stoeber_create(char *name, va_list ap)
struct controller_block_private *private;
int ec_pos;
int i;
int serial_number;
double max_torque, brake_resistor, brake_power;
ec_pos = va_arg(ap, int);
serial_number = va_arg(ap, int);
max_torque = va_arg(ap, double);
brake_resistor = va_arg(ap, double);
brake_power = va_arg(ap, double);
......@@ -261,6 +263,13 @@ struct controller_block *block_stoeber_create(char *name, va_list ap)
if (ec_stoeber_init(&private->stbr))
goto err_stoeber_init;
printf("Drive serial number: %d\n", private->stbr.serial_number);
if (serial_number && serial_number != private->stbr.serial_number) {
printf("Serial number of drive (%d) does not match requested number (%d)\n",
private->stbr.serial_number, serial_number);
goto err_stoeber_init;
}
private->stbr_init = true;
ec_rx_pdo_enable_hook_attach(block_stoeber_rx_enable, stoeber);
......
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009, 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009, 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -101,6 +101,9 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
val8 = 0x00;
canopen_write_param(canopen_dev, STOEBER_PARAM2INDEX('A', 180), 0x0, &val8, 1);
canopen_read_param(canopen_dev, STOEBER_PARAM2INDEX('E', 52), 0x0, &leval32, 4);
stbr->serial_number = le32toh(leval32);
/* A21 brake resistor */
leval16 = htole16(stbr->brake_resistor * 10.0);
canopen_write_param(canopen_dev, STOEBER_PARAM2INDEX('A', 21), 0x0, &leval16, 2);
......
......@@ -51,6 +51,8 @@ struct ec_stoeber {
float standstill_torque;
float brake_resistor;
float brake_power;
uint32_t serial_number;
/* rx pdo */
unsigned char *rx_buffer; /* 14 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment