navit
0.5.3-trunk
|
#include <math.h>
#include <stdio.h>
#include <glib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "config.h"
#include <navit/item.h>
#include <navit/xmlconfig.h>
#include <navit/main.h>
#include <navit/debug.h>
#include <navit/map.h>
#include <navit/navit.h>
#include <navit/callback.h>
#include <navit/file.h>
#include <navit/plugin.h>
#include <navit/event.h>
#include <navit/command.h>
#include <navit/config_.h>
#include "graphics.h"
#include "color.h"
#include "osd.h"
Data Structures | |
struct | j1850 |
Functions | |
void | rand_str (char *dest, size_t length) |
Generates a fake sentence. Used for debugging. More... | |
void | write_to_serial_port (unsigned char *cmd, int device) |
Writes 'cmd' to the serial port'. More... | |
static void | j1850_idle (struct j1850 *j1850) |
Function called when navit is idle. Does the continous reading. More... | |
static void | osd_j1850_draw (struct j1850 *this, struct navit *nav, struct vehicle *v) |
Draws the j1850 OSD. More... | |
static void | osd_j1850_init (struct j1850 *this, struct navit *nav) |
Initialize the j1850 OSD. More... | |
void | send_and_read (unsigned char *cmd, int USB) |
Sends 'cmd' and reads the reply from the device. More... | |
void | j1850_init_serial_port (struct j1850 *j1850) |
Opens the serial port and saves state to the j1850 object. More... | |
static struct osd_priv * | osd_j1850_new (struct navit *nav, struct osd_methods *meth, struct attr **attrs) |
Creates the j1850 OSD and set some default properties. More... | |
void | plugin_init (void) |
The plugin entry point. More... | |
|
static |
Function called when navit is idle. Does the continous reading.
This is the main function of this plugin. It is called when navit is idle, and performs the initialization of the obd device if needed, then reads one char each time it is called, and puts this char in a buffer. When it reads an EOL character, the buffer is parsed, and the appropriate action is taken. The buffer is then cleared and we start over.
References j1850::callback, command_evaluate(), data, dbg, j1850::device, j1850::engine_rpm, event_add_idle(), event_remove_timeout(), j1850::filename, j1850::idle, j1850::index, j1850::init_string_index, lvl_debug, lvl_error, lvl_info, j1850::map, j1850::message, j1850::nav, attr::navit, j1850::odo, rand_str(), j1850::tank_level, j1850::trans_rpm, attr::type, attr::u, value, and write_to_serial_port().
Referenced by j1850_init_serial_port().
void j1850_init_serial_port | ( | struct j1850 * | j1850 | ) |
Opens the serial port and saves state to the j1850 object.
Opens the serial port and saves state to the j1850 object
References j1850::callback, callback_cast, callback_new_1, dbg, j1850::device, event_add_timeout(), j1850::idle, j1850_idle(), and lvl_error.
Referenced by osd_j1850_init().
Draws the j1850 OSD.
[in] | j1850 | - the j1850 struct containing the state of the plugin nav - the navit object v - the vehicle object |
Draws the j1850 OSD. Currently it only displays the last parsed message
References draw_mode_end, graphics::font, osd_item::gr, graphics_draw_mode(), graphics_draw_text(), graphics_get_text_bbox(), osd_item::h, osd_item::w, j1850::white, point::x, and point::y.
Referenced by osd_j1850_init(), and osd_j1850_new().
Initialize the j1850 OSD.
Initialize the j1850 OSD
References color::a, color::b, callback_cast, callback_new_1, event_add_timeout(), color::g, osd_item::gr, graphics_gc_new(), graphics_gc_set_foreground(), graphics_gc_set_linewidth(), j1850_init_serial_port(), j1850::orange, osd_j1850_draw(), osd_set_std_graphic(), color::r, j1850::white, and j1850::width.
Referenced by osd_j1850_new().
|
static |
Creates the j1850 OSD and set some default properties.
[in] | nav | - the navit object meth - the osd_methods attrs - pointer to the attributes |
Creates the j1850 OSD and set some default properties
References attr_search(), callback_cast, callback_new_attr_1, dbg, osd_item_methods::draw, j1850::filename, osd_item::font_size, osd_item::h, j1850::init_string_index, lvl_error, osd_item::meth, j1850::nav, osd_item::navit, navit_add_callback(), attr::num, osd_draw_cast, osd_j1850_draw(), osd_j1850_init(), osd_set_std_attr(), osd_item::p, attr::u, osd_item::w, j1850::width, point::x, and point::y.
Referenced by plugin_init().
void plugin_init | ( | void | ) |
The plugin entry point.
The plugin entry point
References attr_iter::iter, and osd_j1850_new().
void rand_str | ( | char * | dest, |
size_t | length | ||
) |
Generates a fake sentence. Used for debugging.
[in] | dest | - the char * to which we will write the sentence lenght - the length of the sentence to generate |
Generates a fake string to simulate data from the serial port
References j1850::index.
Referenced by j1850_idle().
void send_and_read | ( | unsigned char * | cmd, |
int | USB | ||
) |
void write_to_serial_port | ( | unsigned char * | cmd, |
int | device | ||
) |
Writes 'cmd' to the serial port'.
[in] | cmd | - the char * that we will write to the serial port device - the serial port device |
Write the cmd to the serial port
Referenced by j1850_idle().