aboutsummaryrefslogtreecommitdiffstats
path: root/dvb-t/fi-Tampere_Pyynikki
blob: 76ba2324f64426cd3260450115f8f66639c18194 (plain)
1
2
3
4
5
6
7
# 2012-07-23 Antti Palosaari <crope@iki.fi>
# generated from http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
T 626000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 658000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 682000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 586000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 642000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
me.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* 
 * modbuslog
 *
 * Copyright (C) 2011 Jonathan McCrohan
 *
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// gcc modbuslog.c -o modbuslog `pkg-config --libs --cflags libmodbus libconfig`


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

#include <libconfig.h>
#include <modbus.h>

#define SLAVE_ID 1
#define START_ADDRESS 0
#define NUMBER_REGISTERS 14
#define DEBUG 1

int main(int argc, char *argv[])
{

const char *CONFIG_FILE = "modbuslog.cfg";

 config_t cfg;
 //config_setting_t *setting;

 const char *modbus_device_address;
 int modbus_baud_rate;
 int modbus_data_bits;
 const char *modbus_parity;
 int modbus_stop_bits;

 config_init(&cfg);


  if(!config_read_file(&cfg, CONFIG_FILE))
  {
    fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
            config_error_line(&cfg), config_error_text(&cfg));
    config_destroy(&cfg);
    fprintf(stderr, "Unable to find CONFIG_FILE.\n");
    return -1;
  }

 modbus_t *ctx;
 uint16_t tab_reg[64];
 int rc;
 int i;

 if(!(config_lookup_string(&cfg, "modbus.device", &modbus_device_address)
	&& config_lookup_int(&cfg, "modbus.baud", &modbus_baud_rate)
	&& config_lookup_int(&cfg, "modbus.data_bits", &modbus_data_bits)
	&& config_lookup_string(&cfg, "modbus.parity", &modbus_parity)
	&& config_lookup_int(&cfg, "modbus.stop_bits", &modbus_stop_bits))
){
	fprintf(stderr, "Check modbus configuration in configuration file.\n");
	return -1;
}

 if(DEBUG){
  printf("%s %d %c %d %d\n",modbus_device_address, modbus_baud_rate, modbus_parity[0], modbus_data_bits, modbus_stop_bits);
 }

ctx = modbus_new_rtu(modbus_device_address, modbus_baud_rate, modbus_parity[0], modbus_data_bits, modbus_stop_bits);

modbus_set_slave(ctx, SLAVE_ID);
modbus_set_debug(ctx, DEBUG);

if (ctx == NULL) {
    fprintf(stderr, "Unable to create libmodbus object.\n");
    return -1;
}


if (modbus_connect(ctx) == -1) {
    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
    modbus_free(ctx);
    return -1;
}

rc = modbus_read_input_registers(ctx, START_ADDRESS, NUMBER_REGISTERS, tab_reg);


if (rc == -1) {
    fprintf(stderr, "ERROR: %s\n", modbus_strerror(errno));
    return -1;
}


for (i=0; i < rc; i=i+2) {
    printf("reg[%d]=%d\n", i, tab_reg[i]+tab_reg[i+1]);
}


modbus_close(ctx);
modbus_free(ctx);

    return 0;
}