1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/* Hey EMACS -*- linux-c -*- */
/* $Id$ */
/* libticables2 - link cable library, a part of the TiLP project
* Copyright (C) 1999-2005 Romain Lievin
*
* 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 2 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
This unit allows to trace bytes which are transferred between PC
and TI calculator.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib.h>
#include <glib/gstdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "stdints1.h"
#include "gettext.h"
#include "logging.h"
#include "data_log.h"
#include "log_hex.h"
#include "log_dbus.h"
#include "log_dusb.h"
#include "log_nsp.h"
int log_start(CableHandle *h)
{
gchar *tmp;
tmp = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, LOG_DIR, NULL);
g_mkdir(tmp, 0750);
g_free(tmp);
log_hex_start();
if(h->model == CABLE_USB)
{
log_dusb_start();
log_nsp_start();
}
if(h->model != CABLE_USB)
{
log_dbus_start();
}
return 0;
}
int log_1(CableHandle *h, int dir, uint8_t data)
{
log_hex_1(dir, data);
if(h->model == CABLE_USB)
{
log_dusb_1(dir, data);
log_nsp_1(dir, data);
}
if(h->model != CABLE_USB)
{
log_dbus_1(dir, data);
}
return 0;
}
int log_N(CableHandle *h, int dir, uint8_t *data, int len)
{
int i;
//printf("<%i> ", len);
for(i = 0; i < len; i++)
{
log_hex_1(dir, data[i]);
log_dusb_1(dir, data[i]);
log_dbus_1(dir, data[i]);
log_nsp_1(dir, data[i]);
}
return 0;
}
int log_stop(CableHandle *h)
{
log_hex_stop();
if(h->model == CABLE_USB)
{
log_dusb_stop();
log_nsp_stop();
}
if(h->model != CABLE_USB)
{
log_dbus_stop();
}
return 0;
}
|