#include "stdint.h"
#include <stdlib.h>
#include <string.h>
#include "dn_additional.h"
#include "dn_common.h"
#include "dn_device.h"
#include "dn_udp.h"
#include "dn_com.h"
#include "dn_thread.h"
#include "dn_robotalk.h"
#include "dn_tpcomm.h"
Go to the source code of this file.
Classes | |
struct | CONN_PARAM_TP |
TP communication object. More... | |
struct | TP_FLAGS |
TP flag objects. More... | |
Defines | |
#define | _DEBUG (0) |
#define | _PING_INTERVAL_CONNECT (300) |
A definition for the sending interval of the ping packet when TP connected. | |
#define | _PING_INTERVAL_TPERROR (1000) |
A definition for the sending interval of the ping packet when TP is error state. | |
#define | _TIMER_INTERVAL (10) |
A definition for the interval of the timer event. | |
#define | _TP_CMD_SPECIAL (0x0FFF) |
A definition for the ROBOTalk command which means special command. | |
#define | _TP_INIT_WAIT_CLIENT (100) |
A definition for the wait time of the initialization when the client mode. | |
#define | _TP_INIT_WAIT_SERVER (3000) |
A definition for the wait time of the initialization when the server mode. | |
#define | _TPERROR_TIMEOUT (10000) |
A definition for the timeout which is used to raise disconnect event. | |
#define | _TPLESS_INTERVAL (10000) |
A definition for the interval of the TP less event. | |
Functions | |
static struct CONN_PARAM_TP * | check_address (int index) |
Checks whether the index has been used or not. | |
static int | find_open_address () |
Returns the open address of m_conn_param. | |
static HRESULT | receive_execute (struct CONN_PARAM_TP *tp_param) |
Receives the ROBOTalk packet and executes callback functions. | |
static THRET THTYPE | recv_thread (void *arg) |
The receiving thread. | |
static HRESULT | send_receive (int index, unsigned int retry_timeout, uint16_t command_send, uint8_t *data_send, uint8_t len_send, uint16_t *command_recv, uint8_t *data_recv, uint8_t *len_recv) |
static HRESULT | timer_event (struct CONN_PARAM_TP *tp_param) |
Executes timer event procedure. | |
static THRET THTYPE | timer_thread (void *arg) |
The timer thread. | |
static HRESULT | tp_callfunc (uint16_t command, const uint8_t *data, uint8_t len_data) |
Execute a callback function with the ROBOTalk command. | |
static HRESULT | tp_recv (struct CONN_PARAM_TP *tp_param, unsigned int retry_nak, uint16_t *command, uint8_t *data, uint8_t *len_data) |
static HRESULT | tp_send (struct CONN_PARAM_TP *tp_param, uint16_t command, uint8_t *data, uint8_t len_data) |
HRESULT | TPComm_BEEP (int fd, int16_t time) |
TP beeps. | |
HRESULT | TPComm_Close (int *pfd) |
Ends TP communication. | |
HRESULT | TPComm_DrawLine (int fd, uint8_t start_x, uint8_t start_y, uint8_t end_x, uint8_t end_y, uint8_t color_fg) |
Draws a line to Mini TP. | |
HRESULT | TPComm_DrawMiniTP (int fd, VARIANT commands) |
Sends Draw Mini TP commands. | |
HRESULT | TPComm_DrawRectangle (int fd, uint8_t start_x, uint8_t start_y, uint8_t end_x, uint8_t end_y, uint8_t color_fg, uint8_t color_bg) |
Draws a rectangle to Mini TP. | |
HRESULT | TPComm_DrawString (int fd, BSTR bstr, uint8_t pos_x, uint8_t pos_y, uint8_t size, uint8_t attr, uint8_t color_fg, uint8_t color_bg) |
Draws a string to Mini TP. | |
HRESULT | TPComm_GetTimeout (int fd, uint32_t *timeout) |
Gets timeout. | |
HRESULT | TPComm_GetTPState (int fd, int *state) |
Gets TP state. | |
HRESULT | TPComm_LCD (int fd, int16_t contrast) |
Changes TP LCD. | |
HRESULT | TPComm_LED (int fd, int16_t number, int16_t state) |
Changes TP LED. | |
HRESULT | TPComm_Open (const char *connect, uint32_t timeout, int client, int *pfd) |
Starts TP communication. | |
HRESULT | TPComm_SetCallFunc (const struct CALL_FUNC_TP *func) |
Sets callback functions. | |
HRESULT | TPComm_SetTimeout (int fd, uint32_t timeout) |
Sets timeout. | |
Variables | |
static struct CALL_FUNC_TP | m_call_func |
static struct CONN_PARAM_TP | m_conn_param [TP_CONN_MAX] |
#define _DEBUG (0) |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition at line 50 of file dn_tpcomm.c.
#define _PING_INTERVAL_CONNECT (300) |
A definition for the sending interval of the ping packet when TP connected.
Definition at line 85 of file dn_tpcomm.c.
#define _PING_INTERVAL_TPERROR (1000) |
A definition for the sending interval of the ping packet when TP is error state.
Definition at line 92 of file dn_tpcomm.c.
#define _TIMER_INTERVAL (10) |
A definition for the interval of the timer event.
Definition at line 64 of file dn_tpcomm.c.
#define _TP_CMD_SPECIAL (0x0FFF) |
A definition for the ROBOTalk command which means special command.
Definition at line 57 of file dn_tpcomm.c.
#define _TP_INIT_WAIT_CLIENT (100) |
A definition for the wait time of the initialization when the client mode.
Definition at line 99 of file dn_tpcomm.c.
#define _TP_INIT_WAIT_SERVER (3000) |
A definition for the wait time of the initialization when the server mode.
Definition at line 106 of file dn_tpcomm.c.
#define _TPERROR_TIMEOUT (10000) |
A definition for the timeout which is used to raise disconnect event.
Definition at line 71 of file dn_tpcomm.c.
#define _TPLESS_INTERVAL (10000) |
A definition for the interval of the TP less event.
Definition at line 78 of file dn_tpcomm.c.
struct CONN_PARAM_TP * check_address | ( | int | index | ) | [static, read] |
Checks whether the index has been used or not.
[in] | index | The index of m_conn_param. |
Definition at line 173 of file dn_tpcomm.c.
int find_open_address | ( | ) | [static] |
Returns the open address of m_conn_param.
Definition at line 152 of file dn_tpcomm.c.
HRESULT receive_execute | ( | struct CONN_PARAM_TP * | tp_param | ) | [static] |
Receives the ROBOTalk packet and executes callback functions.
[in] | tp_param | TP communication object. |
Definition at line 452 of file dn_tpcomm.c.
THRET recv_thread | ( | void * | arg | ) | [static] |
The receiving thread.
[in] | arg | The argument of receiving thread: CONN_PARAM_TP. |
Definition at line 663 of file dn_tpcomm.c.
static HRESULT send_receive | ( | int | index, |
unsigned int | retry_timeout, | ||
uint16_t | command_send, | ||
uint8_t * | data_send, | ||
uint8_t | len_send, | ||
uint16_t * | command_recv, | ||
uint8_t * | data_recv, | ||
uint8_t * | len_recv | ||
) | [static] |
Definition at line 394 of file dn_tpcomm.c.
HRESULT timer_event | ( | struct CONN_PARAM_TP * | tp_param | ) | [static] |
Executes timer event procedure.
[in] | tp_param | TP communication object. |
Definition at line 583 of file dn_tpcomm.c.
THRET timer_thread | ( | void * | arg | ) | [static] |
The timer thread.
[in] | arg | The argument of timer thread: CONN_PARAM_TP. |
Definition at line 697 of file dn_tpcomm.c.
HRESULT tp_callfunc | ( | uint16_t | command, |
const uint8_t * | data, | ||
uint8_t | len_data | ||
) | [static] |
Execute a callback function with the ROBOTalk command.
[in] | command | The received ROBOTalk command. |
[in] | data | The received ROBOTalk data. |
[in] | len_data | The length of received ROBOTalk data. |
Definition at line 195 of file dn_tpcomm.c.
static HRESULT tp_recv | ( | struct CONN_PARAM_TP * | tp_param, |
unsigned int | retry_nak, | ||
uint16_t * | command, | ||
uint8_t * | data, | ||
uint8_t * | len_data | ||
) | [static] |
Definition at line 321 of file dn_tpcomm.c.
static HRESULT tp_send | ( | struct CONN_PARAM_TP * | tp_param, |
uint16_t | command, | ||
uint8_t * | data, | ||
uint8_t | len_data | ||
) | [static] |
Definition at line 287 of file dn_tpcomm.c.
HRESULT TPComm_BEEP | ( | int | fd, |
int16_t | time | ||
) |
TP beeps.
[in] | fd | File descriptor. |
[in] | time | Beeping time. |
Definition at line 1002 of file dn_tpcomm.c.
HRESULT TPComm_Close | ( | int * | pfd | ) |
Ends TP communication.
[in,out] | pfd | The pointer of File descriptor. |
Definition at line 885 of file dn_tpcomm.c.
HRESULT TPComm_DrawLine | ( | int | fd, |
uint8_t | start_x, | ||
uint8_t | start_y, | ||
uint8_t | end_x, | ||
uint8_t | end_y, | ||
uint8_t | color_fg | ||
) |
Draws a line to Mini TP.
[in] | fd | File descriptor. |
[in] | start_x | The start position for axis X. |
[in] | start_y | The start position for axis Y. |
[in] | end_x | The end position for axis X. |
[in] | end_y | The end position for axis Y. |
[in] | color_fg | The color of drawing line. |
Definition at line 1264 of file dn_tpcomm.c.
HRESULT TPComm_DrawMiniTP | ( | int | fd, |
VARIANT | commands | ||
) |
Sends Draw Mini TP commands.
[in] | fd | File descriptor. |
[in] | commands | Mini TP commands. |
Definition at line 1062 of file dn_tpcomm.c.
HRESULT TPComm_DrawRectangle | ( | int | fd, |
uint8_t | start_x, | ||
uint8_t | start_y, | ||
uint8_t | end_x, | ||
uint8_t | end_y, | ||
uint8_t | color_fg, | ||
uint8_t | color_bg | ||
) |
Draws a rectangle to Mini TP.
[in] | fd | File descriptor. |
[in] | start_x | The start position for axis X. |
[in] | start_y | The start position for axis Y. |
[in] | end_x | The end position for axis X. |
[in] | end_y | The end position for axis Y. |
[in] | color_fg | The color of drawing rectangle. |
[in] | color_fg | The background color of drawing rectangle. |
Definition at line 1311 of file dn_tpcomm.c.
HRESULT TPComm_DrawString | ( | int | fd, |
BSTR | bstr, | ||
uint8_t | pos_x, | ||
uint8_t | pos_y, | ||
uint8_t | size, | ||
uint8_t | attr, | ||
uint8_t | color_fg, | ||
uint8_t | color_bg | ||
) |
Draws a string to Mini TP.
[in] | fd | File descriptor. |
[in] | bstr | The drawing string. |
[in] | pos_x | The drawing position for axis X. |
[in] | pos_y | The drawing position for axis Y. |
[in] | size | The size of drawing string. |
[in] | attr | The attribute of drawing string. |
[in] | color_fg | The color of drawing string. |
[in] | color_bg | The background color of drawing string. |
Definition at line 1203 of file dn_tpcomm.c.
HRESULT TPComm_GetTimeout | ( | int | fd, |
uint32_t * | timeout | ||
) |
Gets timeout.
[in] | fd | File descriptor. |
[out] | timeout | The gotten timeout value. |
Definition at line 966 of file dn_tpcomm.c.
HRESULT TPComm_GetTPState | ( | int | fd, |
int * | state | ||
) |
Gets TP state.
[in] | fd | File descriptor. |
[out] | state | The gotten TP state. |
Definition at line 985 of file dn_tpcomm.c.
HRESULT TPComm_LCD | ( | int | fd, |
int16_t | contrast | ||
) |
Changes TP LCD.
[in] | fd | File descriptor. |
[in] | contrast | The LCD value. (0: The most darken, 7: The most brightest) note It will take 2 or more seconds to reflect the set LDC value completely. |
Definition at line 1047 of file dn_tpcomm.c.
HRESULT TPComm_LED | ( | int | fd, |
int16_t | number, | ||
int16_t | state | ||
) |
Changes TP LED.
[in] | fd | File descriptor. |
[in] | number | The LED number. (1: MORTOR, 2: LOCK, -1: Both) |
[in] | state | State to be changed. (0: OFF, 1: ON, 2: FLASH) |
Definition at line 1017 of file dn_tpcomm.c.
HRESULT TPComm_Open | ( | const char * | connect, |
uint32_t | timeout, | ||
int | client, | ||
int * | pfd | ||
) |
Starts TP communication.
[in] | connect | Connection parameters. |
[in] | timeout | Timeout value. |
[in] | client | TP mode flag. (Client: = 1, Server: 0) |
[out] | pfd | The pointer of File descriptor. |
Definition at line 748 of file dn_tpcomm.c.
HRESULT TPComm_SetCallFunc | ( | const struct CALL_FUNC_TP * | func | ) |
Sets callback functions.
[in] | func | Callback functions to be set. |
Definition at line 737 of file dn_tpcomm.c.
HRESULT TPComm_SetTimeout | ( | int | fd, |
uint32_t | timeout | ||
) |
Sets timeout.
[in] | fd | File descriptor. |
[in] | timeout | Timeout value to be set. |
Definition at line 935 of file dn_tpcomm.c.
struct CALL_FUNC_TP m_call_func [static] |
Definition at line 144 of file dn_tpcomm.c.
struct CONN_PARAM_TP m_conn_param[TP_CONN_MAX] [static] |
Definition at line 143 of file dn_tpcomm.c.