--- /dev/null
+;; -*- emacs-lisp -*-
+;;
+;; This file is processed by the dirvars emacs package. Each variable
+;; setting below is performed when this dirvars file is loaded.
+;;
+c-basic-offset: 2
+indent-tabs-mode: nil
+tab-width: 2
+;show-trailing-whitespace: t
+;indicate-empty-lines: t
+
#bth_comp2_LIBS = boot_fn arch_drivers excptvec misc pxmc m sci_channels bluetooth
#bth_comp2_MOREOBJS = $(USER_LIB_DIR)/system_stub.o
-lib_LIBRARIES = bluetooth
+lib_LIBRARIES = mirobt
-bluetooth_SOURCES = bth_command.c bth_event_acc.c bth_error.c bth_cmd_complete_ev.c l2cap.c bth_inface.c bth_main.c h2638_pkt_controll.c
+mirobt_SOURCES = bth_command.c bth_event_acc.c bth_error.c \
+bth_cmd_complete_ev.c l2cap.c bth_inface.c bth_main.c
+
+ifeq ($(CONFIG_BLUETOOTH_LINUX),y)
+mirobt_SOURCES += hci_bluez.c fake_pkt_controll.c
+else
+mirobt_SOURCES += hci_sci.c h2638_pkt_controll.c
+endif
include_HEADERS = bth_inface.h bth_fce_out.h bth_h8s2638.h
-default_CONFIG = CONFIG_BLUETOOTH=y
\ No newline at end of file
+default_CONFIG += CONFIG_BLUETOOTH=y
+default_CONFIG += CONFIG_BLUETOOTH_LINUX=n
+
+config_include_HEADERS = bth_config.h
+bth_config_DEFINES = $(default_CONFIG)
\r
*******************************************************************/\r
\r
+#include <bth_config.h>\r
#include <string.h>\r
#include <stdlib.h>\r
#ifdef BTH_LX\r
#include <periph/sci_rs232.h>\r
-#include <types.h>\r
//#include <assert.h>\r
#endif\r
-#include "types.h"\r
+#include <types.h>\r
#include "hci.h"\r
#include "inline_fce.h"\r
#include "hci_event.h"\r
read_bd_addr_rp bth_q;\r
\r
int index;\r
- store16(bth_q.status,*((uint8_t*)bth_p+READ_BD_ADDR_RP____status));\r
+ store8(bth_q.status,*((uint8_t*)bth_p+READ_BD_ADDR_RP____status));\r
memcpy(&bth_local_info.bdaddr,((uint8_t*)bth_p+READ_BD_ADDR_RP____bdaddr),6);\r
index=bth_del_event(btohs(0x0910)); //obcode read_bd_addr\r
if(index==-1)\r
// assert(index >= 0 && index < LANCOMMAND);\r
if(*((uint8_t*)bth_p+READ_BD_ADDR_RP____status)==0)\r
{\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
return 0; //prikaz probehl bez komplikaci\r
}\r
else\r
{\r
/*status is not OK */\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
return((int)*((uint8_t*)bth_p+READ_BD_ADDR_RP____status)); //NOTE probably I put * here, but I don't remember it. It was yesterday >-]\r
};\r
};\r
\r
#include <string.h>\r
#include <stdlib.h>\r
-#ifdef BTH_LX\r
#include <types.h>\r
+#ifdef BTH_LX\r
#include <cpu_def.h>\r
#include <h8s2638h.h>\r
#include <periph/sci_rs232.h>\r
#include <system_def.h>\r
-\r
-#else\r
-#include "types.h"\r
#endif\r
\r
#include "hci.h"\r
/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+INQUIRY_CP_SIZE);\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //possition in buff, which is assigned to the packet\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //possition in buff, which is assigned to the packet\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head\r
bth_cmd_packet=(inquiry_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer to parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+SET_CONN_PTYPE_CP_SIZE);\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(set_conn_ptype_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+DISCONNECT_CP_SIZE;\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(disconnect_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+WRITE_LINK_POLICY_CP_SIZE;\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(write_link_policy_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE;\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
\r
store16(*typ_hci_paket, HCI_COMMAND_PKT);\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+ACCEPT_CONN_REQ_CP_SIZE);\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(accept_conn_req_cp*)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);\r
\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(write_page_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(write_inq_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE);\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
\r
store16(*typ_hci_paket, HCI_COMMAND_PKT);\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_SCAN_ENABLE_SIZE);\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+ typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
bth_cmd_packet=(uint8_t *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
\r
-#ifdef BTH_LX\r
#include <types.h>\r
+#ifdef BTH_LX\r
#include <cpu_def.h>\r
#include <h8s2638h.h>\r
#include <system_def.h>\r
#include <periph/sci_rs232.h>\r
-#else\r
-#include "types.h"\r
#endif\r
\r
#include <stdlib.h>\r
*/\r
void bth_error_detect_status(uint8_t status_num)\r
{\r
- uint8_t *message;\r
+ char *message;\r
int i=0;\r
if(status_num<sizeof(status_command));\r
{\r
*/\r
void bth_error_detect_event(uint8_t status_num)\r
{\r
- uint8_t *message;\r
+ char *message;\r
int i=0;\r
if(status_num<sizeof(event_command));\r
{\r
\r
#include <string.h>\r
#include <stdlib.h>\r
-#include "types.h"\r
+#include <types.h>\r
#include "hci.h"\r
#include "l2cap.h"\r
#include "hci_event.h"\r
uint16_t opcode_pkt;\r
for(i=0;i<LENCOMMAND;i++)\r
{\r
- if(bth_pole_adrr_check_packet[i]!=NULL)\r
+ if(bth_array_adrr_check_packet[i]!=NULL)\r
{\r
- __bthtomc16(&opcode_pkt,((uint8_t*)bth_pole_adrr_check_packet[i]+HCI_PKT_SIZE));\r
+ __bthtomc16(&opcode_pkt,((uint8_t*)bth_array_adrr_check_packet[i]+HCI_PKT_SIZE));\r
if(opcode_pkt==opcode)\r
{return i;};\r
};\r
VypisHexa((void*)&(((bths_connect_bluet*)bth_connected[j])->handle),2);\r
sci_rs232_sendch('c',sci_rs232_chan_default); //do PC*/\r
\r
- store16(bth_q->link_type,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____link_type));\r
- store16(bth_q->encr_mode,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____encr_mode));\r
+ store8(bth_q->link_type,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____link_type));\r
+ store8(bth_q->encr_mode,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____encr_mode));\r
\r
bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //reply\r
return (*((uint8_t*)bth_p+EVT_CONN_COMPLETE____status));\r
uint16_t opcode,ogf,ocf;\r
int index=-1;\r
\r
- store16(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_COMPLETE____ncmd));\r
+ store8(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_COMPLETE____ncmd));\r
// store_le16(&bth_q.opcode,*((uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)));\r
__bthtomc16(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)));\r
index=bth_del_event(bth_q.opcode);\r
{\r
if(*((uint8_t*)bth_p+3)==0)\r
{\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
bth_local_info.busy=0;\r
return 0; //no complications was encountered during command execution\r
}\r
else\r
{\r
/*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
bth_local_info.busy=0;\r
return((int)*((uint8_t*)bth_p+EVT_CMD_COMPLETE_SIZE));\r
};\r
int bth_evt_cmd_status(uint8_t *bth_p, uint8_t size) //0x0F\r
{\r
evt_cmd_status bth_q;\r
- store16(bth_q.status,*((uint8_t*)bth_p+EVT_CMD_STATUS____status));\r
- store16(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_STATUS____ncmd));\r
+ store8(bth_q.status,*((uint8_t*)bth_p+EVT_CMD_STATUS____status));\r
+ store8(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_STATUS____ncmd));\r
// store_le16(&bth_q.opcode,*((uint16_t*)((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)));\r
- __bthtomc16(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)));\r
+ __bthtomc8(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)));\r
// memcpy(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)),2);\r
uint8_t ogf, ocf;\r
int index;\r
{\r
if(bth_q.status==0)\r
{\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
}\r
else\r
{\r
/*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
- free(bth_pole_adrr_check_packet[index]);\r
- bth_pole_adrr_check_packet[index]=NULL;\r
+ free(bth_array_adrr_check_packet[index]);\r
+ bth_array_adrr_check_packet[index]=NULL;\r
};\r
}\r
else\r
*******************************************************************/
+#include <types.h>
+
int bth_send_queue(void);
Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
*******************************************************************/
+
+#include <bth_config.h>
#ifdef BTH_LX
#include <types.h>
#include "bth_inface.h"
#include "bth_inface.h"
+#ifndef CONFIG_BLUETOOTH_LINUX
#include <periph/sci_rs232.h>
+#endif
/* the number of communication structures i.e. how many channels can be used for communication. It alse specifies howmany
independent couples of I/O buffers is here.*/
return (-1);
}
-/**
- * fce write one char to out-buffer. Fce return a code of char. If a value is -1 its signal for error
-*/
-int bth_inface_sendch(int val, int chan)
-{
- if(bth_inface_que_put(&(bth_inface_chan_array[chan].bth_inface_que_out),val)<0)
- {return (-1);};
- return (val);
-};
-
-
-/**
- * fce read one char of in-buffer. Fce return a code of char. If is a value -1 than is not new char
-*/
-int bth_inface_recch(int chan)
-{
- short val;
- if((val=bth_inface_que_get(&(bth_inface_chan_array[chan].bth_inface_que_in)))>=0)
- {
- sci_rs232_sendch(val,sci_rs232_chan_default);
- return val;
- }
- return (-1);
-};
-
-
/**
* init buffer for first chanal - 0 (nm. is index of array)
*/
#ifndef _ID_BTH_INFACE_H_
#define _ID_BTH_INFACE_H_
+#include <bth_config.h>
+#include <types.h>
+#ifdef CONFIG_BLUETOOTH_LINUX
+#endif
+
#define BTH_INFACE_CHANAL (1)
#define BTH_INFACE_BUF_LEN (70)
int bth_inface_r_isr(int chan, int val);
int bth_inface_t_isr(int chan);
-/* HACK: Include machine specific definitions */
#endif /* _ID_BTH_INFACE_H_ */
Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
*******************************************************************/
-#ifdef BTH_LX
+#include <bth_config.h>
#include <types.h>
+#ifdef BTH_LX
#include <cpu_def.h>
#include <h8s2638h.h>
#include <periph/sci_rs232.h>
#include <system_def.h>
#include <string.h>
#else
-#include "types.h"
#include <stdio.h>
#endif
#include "bth_inface.h"
#include "bth_fce_out.h"
#include "bth_h8s2638.h"
-#include <periph/sci_rs232.h>
+
+
+#define BTH_BUF_LEN 300
/*--------BD address whitch are accept for connection-------------*/
bdaddr_t bth_accept_bd_addr[]={};
bths_connect_bluet* bth_connected[8];
/*-------------------------------- recieve data buffer -----------------------------*/
-uint8_t bth_pole_char_in[SCI_BTH_BUF_LEN];
bth_que_t bth_rs232_que_in;
-uint8_t bth_rs232_buf_in[SCI_BTH_BUF_LEN];
-//-- --- ----- ----- ---- ------ ----- -- ---- --
-//-- --- ----- ----- ---- ------ ----- -- ---- --
-bth_que_t bth_inface_que_in;
-bth_que_t bth_inface_que_out;
+//bth_que_t bth_inface_que_in;
+//bth_que_t bth_inface_que_out;
-void *bth_pole_adrr_comm_packet[LENCOMMAND]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
+void *bth_array_adrr_comm_packet[LENCOMMAND]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
bths_command_buf_info bth_com_buf_info={LENCOMMAND,0,0};
/***********************************************************************************/
-void *bth_pole_adrr_check_packet[LENCOMMAND]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
+void *bth_array_adrr_check_packet[LENCOMMAND]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
bths_command_buf_info bth_check_buf_info={LENCOMMAND,0,0};
/***********************************************************************************/
int i;
int hp_size;
if(bth_local_info.busy!=0)
- {return 1;}; //device is busy
+ {return 1;}; //device is busy
if(bth_com_buf_info.aktual==bth_com_buf_info.sent) //PRAVDEPODOBNE neni co odesilat
{
if(bth_com_buf_info.sent<(LENCOMMAND-2))
{
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.sent+1]==NULL)
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.sent+1]==NULL)
{return 1;}; //There is certainly nothing to send
}
else
{
- if(bth_pole_adrr_comm_packet[0]==NULL)
+ if(bth_array_adrr_comm_packet[0]==NULL)
{return 1;}; //There is certainly nothing to send
};
};
/*bth_send_packet(AdrFrom,howmanyBytes;)*/
- switch(*(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.sent])
- {
- case HCI_ACLDATA_PKT:
- __bthtomc16((uint8_t*)&(hp_size),((uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.sent])+HCI_PKT_SIZE+HCI_ACL_HDR____dlen);
- hp_size=hp_size+HCI_ACL_HDR_SIZE+HCI_PKT_SIZE;
- if(!(bth_send_packet(bth_pole_adrr_comm_packet[bth_com_buf_info.sent],hp_size)))
+ switch(*(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.sent])
+ {
+ case HCI_ACLDATA_PKT:
+ __bthtomc16((uint8_t*)&(hp_size),((uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.sent])+HCI_PKT_SIZE+HCI_ACL_HDR____dlen);
+ hp_size=hp_size+HCI_ACL_HDR_SIZE+HCI_PKT_SIZE;
+ if(!(bth_send_packet(bth_array_adrr_comm_packet[bth_com_buf_info.sent],hp_size)))
+ {
+ free(bth_array_adrr_comm_packet[bth_com_buf_info.sent]);
+ bth_array_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
+ if(bth_com_buf_info.sent<(LENCOMMAND-2)){bth_com_buf_info.sent++;}
+ else{ bth_com_buf_info.sent=0;};
+ return(0);
+ };
+ free(bth_array_adrr_comm_packet[bth_com_buf_info.sent]);
+ bth_array_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
+ return (-6);
+ case HCI_COMMAND_PKT:
+ hp_size=((uint16_t)*(((uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.sent])+HCI_PKT_SIZE+2)+HCI_COMMAND_HDR_SIZE+HCI_PKT_SIZE);
+ if(!(bth_send_packet(bth_array_adrr_comm_packet[bth_com_buf_info.sent],hp_size)))
+ {/*sent - add the command to allow confirmation*/
+ for(i=0; i<LENCOMMAND; i++)
{
- free(bth_pole_adrr_comm_packet[bth_com_buf_info.sent]);
- bth_pole_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
- if(bth_com_buf_info.sent<(LENCOMMAND-2)){bth_com_buf_info.sent++;}
- else{ bth_com_buf_info.sent=0;};
- return(0);
- };
- free(bth_pole_adrr_comm_packet[bth_com_buf_info.sent]);
- bth_pole_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
- return (-6);
- case HCI_COMMAND_PKT:
- hp_size=((uint16_t)*(((uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.sent])+HCI_PKT_SIZE+2)+HCI_COMMAND_HDR_SIZE+HCI_PKT_SIZE);
- if(!(bth_send_packet(bth_pole_adrr_comm_packet[bth_com_buf_info.sent],hp_size)))
- {/*sent - add the command to allow confirmation*/
- for(i=0; i<LENCOMMAND; i++)
+ if(bth_array_adrr_check_packet[i]==NULL)
{
- if(bth_pole_adrr_check_packet[i]==NULL)
- {
- bth_pole_adrr_check_packet[i]=bth_pole_adrr_comm_packet[bth_com_buf_info.sent];
- bth_pole_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
- /*set the address for the next command - principle of ring buffer*/
- if(bth_com_buf_info.sent<(LENCOMMAND-2)){bth_com_buf_info.sent++;}
- else{ bth_com_buf_info.sent=0;};
- return 0;
- }
- };
- return(-7);
+ bth_array_adrr_check_packet[i]=bth_array_adrr_comm_packet[bth_com_buf_info.sent];
+ bth_array_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
+ /*set the address for the next command - principle of ring buffer*/
+ if(bth_com_buf_info.sent<(LENCOMMAND-2)){bth_com_buf_info.sent++;}
+ else{ bth_com_buf_info.sent=0;};
+ return 0;
+ }
};
- return(-6);
- };
+ return(-7);
+ };
+ return(-6);
+ };
return (1);
};
// OUTPUT :none
//***************************************************************************
void bth_conv_char_text(uint8_t zn)
-{ uint8_t map_leters[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+{
uint8_t val;
val=(zn&0xf0)>>4;
#ifdef BTH_LX
+ uint8_t map_leters[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
sci_rs232_sendch(map_leters[val],sci_rs232_chan_default);
val=(zn&0x0f);
sci_rs232_sendch(map_leters[val],sci_rs232_chan_default);
-/**
- //FIXME
- *Sends data of the size hp_size from address hp to the bluetooth device (UART)
- */
-int bth_send_packet(uint8_t *hp, uint16_t hp_size)
-{
- int zn,i;
- /*is bluetooth device free, or is it busy by the previous command?*/
- if(bth_local_info.busy==0)
- {
-#ifndef BTH_LX
- VypisHexa(hp,hp_size);
-#else
-
- for(i=0; i<hp_size;i++)
- {
- zn=*(hp+i);
- sci_rs232_sendch(zn,2); //bth
-// VypisHexa((hp+i),1);
- };
-#endif
- bth_local_info.busy=1;
- return(0); //everything sent ==== OK =====
- }
- else
- {
- return 2; //busy
- };
-};
-
/**
*Inserts a character to the queue
*/
-inline int bth_que_put(bth_que_t *q, int c)
+static inline int bth_que_put(bth_que_t *q, int c)
{
uint8_t *p;
p=q->ip; //FIXME set us to the actual position in the file
{
case HCI_EVENT_PKT:
/*fill in structure "hci_event_hdr" from the queue (bye by byte)*/
- store16(bth_event_packet.evt, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE));
- store16(bth_event_packet.plen, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+1));
+ store8(bth_event_packet.evt, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE));
+ store8(bth_event_packet.plen, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+1));
if(bth_rs232_que_in.ip-bth_rs232_que_in.buf_beg>3)
{
bth_acl_packet.handle=bth_acl_packet.handle & 0x0fff;
/*variable 'char_acl_pkt' stores the properties of the packet, if it is point to point or broadcast, or char. L2CAP*/
- store16(char_acl_pkt, (0xf0&*(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+HCI_ACL_HDR____handle+1)));
+ store8(char_acl_pkt, (0xf0&*(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+HCI_ACL_HDR____handle+1)));
/*decide which packet is this (PtP,Piconet,broat...) and the type of communication (L2CAP, HCI)*/
data_ad=(uint8_t*)bth_rs232_que_in.buf_beg+HCI_PKT_SIZE+HCI_ACL_HDR_SIZE;
*/
void bth_init(void)
{
+ static uint8_t bth_array_char_in[70];
// bth_check_command_for_send=NULL;
- bth_rs232_que_in.buf_end=(uint8_t*)bth_pole_char_in+SCI_RS232_BUF_LEN;
- bth_rs232_que_in.buf_beg=bth_pole_char_in;
- bth_rs232_que_in.ip=bth_pole_char_in;
+ bth_rs232_que_in.buf_end=(uint8_t*)bth_array_char_in+BTH_BUF_LEN;
+ bth_rs232_que_in.buf_beg=bth_array_char_in;
+ bth_rs232_que_in.ip=bth_array_char_in;
};
/****************************************************************************/
#ifndef BTH_RECEIVE_H\r
#define BTH_RECEIVE_H\r
\r
-#define SCI_BTH_BUF_LEN 70 \r
typedef struct{\r
uint8_t *buf_beg; //start of adress structur\r
uint8_t *buf_end; //end of adress structur - beg+sizeof(struct)\r
--- /dev/null
+/*******************************************************************
+ bluetooth library
+
+ h2638_pkt_control.c - fce for TPU operation
+
+ Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
+
+ *******************************************************************/
+
+#include <stdlib.h>
+#include "hci.h"
+#include "bth_h8s2638.h"
+
+
+long int timer;
+
+/**
+ * Starts TPU channel 1
+*/
+void bth_start_TPU_counter(void)
+{
+};
+
+
+/**
+ * Stop TPU 1
+ */
+void bth_stop_TPU_counter(void)
+{
+};
+
+
+/**
+ * Reset TPU 1
+ */
+void bth_clear_TPU_counter(void)
+{
+};
+
+/**
+ * Returns the number of timer interrupts
+ */
+long int bth_get_timer(void)
+{
+ return timer;
+};
+
+/**
+ * Zeroes the timer variable
+ */
+void bth_nul_timer(void)
+{
+ timer=0;
+};
+
+
+/**
+ * Timer initialization - HW 1-timer overflow; 2-???Dosazeni citace hodnoty TIER1_TGIEAm
+ */
+void bth_init_pkt_controll(void)
+{
+};
+
/*******************************************************************
bluetooth library
- hci.h - main structures for keeping an information about a queie, definition of global val,
- and any macros and inline fce
+ hci.h - main structures for keeping an information about a queue,
+ definition of global val, and any macros and inline fce
Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
#ifndef HCI_H_H
#define HCI_H_H
+#include <bth_config.h>
+#include <types.h>
+#ifdef CONFIG_BLUETOOTH_LINUX
+#include <stddef.h>
+#endif
+
/* Byte order conversions */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htobs(d) (d)
// }
/*pro typ char (nikoliv u16)*/
-#define store16(field, val) field=val;
+#define store8(field, val) field=val;
// Returns an offset of a field in a structure
extern bths_connect_bluet *bth_connected[];
//extern void *bth_for_connecting[];
-/*---------------- queue prikazova a potvrzovaci-----------------------*/
-#define LENCOMMAND 10
-extern void *bth_pole_adrr_comm_packet[LENCOMMAND];
+/*---------------- command and acknowledge queues -----------------------*/
+#define LENCOMMAND 10
+extern void *bth_array_adrr_comm_packet[LENCOMMAND];
extern bths_command_buf_info bth_com_buf_info;
-extern void *bth_pole_adrr_check_packet[LENCOMMAND];
+extern void *bth_array_adrr_check_packet[LENCOMMAND];
extern bths_command_buf_info bth_check_buf_info;
extern uint8_t bth_controll_flag;
--- /dev/null
+#include "hci.h"
+#include <unistd.h>
+int hci_socket;
+/**
+ //FIXME
+ *Sends data of the size hp_size from address hp to the bluetooth device (UART)
+ */
+int bth_send_packet(uint8_t *hp, uint16_t hp_size)
+{
+ /*is bluetooth device free, or is it busy by the previous command?*/
+ if(bth_local_info.busy==0) {
+
+ write(hci_socket, hp, hp_size);
+
+ bth_local_info.busy=1;
+ return(0); //everything sent ==== OK =====
+ } else {
+ return 2; //busy
+ };
+};
+
--- /dev/null
+#include <hci.h>
+
+/**
+ //FIXME
+ *Sends data of the size hp_size from address hp to the bluetooth device (UART)
+ */
+int bth_send_packet(uint8_t *hp, uint16_t hp_size)
+{
+ /*is bluetooth device free, or is it busy by the previous command?*/
+ if(bth_local_info.busy==0) {
+#ifndef BTH_LX
+ VypisHexa(hp,hp_size);
+#else
+ int zn,i;
+
+ for(i=0; i<hp_size;i++) {
+ zn=*(hp+i);
+ sci_rs232_sendch(zn,2); //bth
+// VypisHexa((hp+i),1);
+ };
+#endif
+ bth_local_info.busy=1;
+ return(0); //everything sent ==== OK =====
+ } else {
+ return 2; //busy
+ };
+};
+
\r
#include <string.h>\r
#include <stdlib.h>\r
-#ifdef BTH_LX\r
#include <types.h>\r
+#ifdef BTH_LX\r
#include <cpu_def.h>\r
#include <h8s2638h.h>\r
#include <periph/sci_rs232.h>\r
#include <system_def.h>\r
-\r
-#else\r
-#include "types.h"\r
#endif\r
\r
#include "hci.h"\r
/**\r
* Search the cannels of the connected device dev_num and search the channel dcid\r
*/\r
-inline int l2cap_find_dcid(int dcid, int dev_num )\r
+static inline int l2cap_find_dcid(int dcid, int dev_num )\r
{\r
int i;\r
for(i=1;i<L2CAP_NUM_OF_CANAL;i++)\r
\r
int l2cap_add_to_send_buffer(uint8_t *bth_p)\r
{\r
- if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
+ if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
- bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=bth_p;\r
+ bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=bth_p;\r
\r
/*set the position in command array for the next command. If it is possible to write there (if the pointer = NULL) is checked by the writer. .\r
\r
+++ /dev/null
-#ifndef _H8S_TYPES_H
-#define _H8S_TYPES_H
-
-
-typedef unsigned short umode_t;
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-#if __INT_MAX__ == 32767
-typedef __signed__ long __s32;
-typedef unsigned long __u32;
-#else
-typedef int __s32;
-typedef unsigned int __u32;
-#endif
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-
-typedef __u8 uint8_t;
-typedef __s8 int8_t;
-typedef __u16 uint16_t;
-typedef __s16 int16_t;
-typedef __u32 uint32_t;
-typedef __s32 int32_t;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __s64 int64_t;
-typedef __u64 uint64_t;
-#endif
-
-#endif /* !(__BIT_TYPES_DEFINED__) */
-
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-typedef __s8 s8;
-typedef __u8 u8;
-
-typedef __s16 s16;
-typedef __u16 u16;
-
-typedef __s32 s32;
-typedef __u32 u32;
-
-typedef __s64 s64;
-typedef __s64 u64;
-
-#define BITS_PER_LONG 32
-
-#endif /* __KERNEL__ */
-
-#endif /* _H8S_TYPES_H */
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+# All subdirectories (even linked) with Makefile.omk
+SUBDIRS := $(shell find -L $(SOURCES_DIR) -maxdepth 2 -mindepth 2 -name Makefile.omk|sed 's!$(SOURCES_DIR)/\(.*\)/.*!\1!')
--- /dev/null
+# Makefile.rules - OCERA make framework common project rules -*- makefile -*- #OMK@base
+#
+# (C) Copyright 2003 by Pavel Pisa - OCERA team member
+# (C) Copyright 2006 by Michal Sojka - Czech Technical University, FEE, DCE
+#
+# Version for Linux/RTLinux builds. #OMK@linux
+#
+# #OMK@base
+# input variables
+# V .. if set to 1, full command text is shown else short form is used
+# SUBDIRS .. list of subdirectories intended for make from actual directory
+# default_CONFIG .. list of default config assignments CONFIG_XXX=y/n ...
+# LOCAL_CONFIG_H .. name of local config.h file generated from values #OMK@config_h
+# of options defined in the current directory
+# config_include_HEADERS .. names of global config files (possibly
+# with subdirectories)
+# xxx_DEFINES .. list of config directives to be included in
+# config header file of the name <somedir>/xxx.h
+# LN_HEADERS .. if "y", header files are symbolicaly linked instead of copied. #OMK@include
+# #OMK@linux
+# input variables
+# lib_LIBRARIES .. list of the user-space libraries
+# shared_LIBRARIES .. list of the user-space shared libraries
+# kernel_LIBRARIES .. list of the kernel-space libraries
+# rtlinux_LIBRARIES.. list of the RT-Linux kernel-space libraries
+# include_HEADERS .. list of the user-space public header files
+# nobase_include_HEADERS .. public headers copied even with directory part
+# renamed_include_HEADERS .. public headers copied to the different target name
+# kernel_HEADERS .. list of the kernel-space public header files
+# rtlinux_HEADERS .. list of the RT-Linux kernel-space public header files
+# bin_PROGRAMS .. list of the require binary programs
+# utils_PROGRAMS .. list of the development utility programs
+# kernel_MODULES .. list of the kernel side modules/applications
+# rtlinux_MODULES .. list of RT-Linux the kernel side modules/applications
+# xxx_SOURCES .. list of specific target sources
+# INCLUDES .. additional include directories and defines for user-space
+# kernel_INCLUDES .. additional include directories and defines for kernel-space
+# rtlinux_INCLUDES .. additional include directories and defines for RT-Linux
+# OMIT_KERNEL_PASSES if defined, all kernel passes are omited
+#
+# LINUX_DIR .. location of Linux kernel sources
+# RTL_DIR .. location of RT-Linux sources
+# QT_SUBDIRS .. subdirectories where to build QT applications using qmake #OMK@qt
+# QTDIR .. where QT resides
+-include $(MAKERULES_DIR)/OCERA_TOP_DIR #OMK@linux-setup
+
+BUILD_DIR_NAME = _build
+COMPILED_DIR_NAME = _compiled
+ifndef GROUP_DIR_NAME
+GROUP_DIR_NAME = nogroup
+endif
+
+ifdef OCERA_DIR
+ifeq ($(wildcard $(OCERA_DIR)/ocera.mk),)
+$(warning "ocera.mk" file does not exist. Adapt Makefile.rules for standalone compilation)
+$(warning (comment out definition of OCERA_DIR line and optionally select RTL_DIR) )
+$(error or go to the ocera/ directory and do 'make' to generate the "ocera.mk" file first, please)
+endif
+include $(OCERA_DIR)/ocera.mk
+KERN_INCLUDE_DIR := $(OCERA_KERNEL_INCLUDES_DIR)
+KERN_LIB_DIR := $(OCERA_KERNEL_LIBRARIES_DIR)
+KERN_MODULES_DIR := $(OCERA_MODULES_DIR)
+KERN_BUILD_DIR := $(BUILD_DIR)/kern/$(GROUP_DIR_NAME)
+KERN_MODPOST_DIR := $(BUILD_DIR)/kern-modpost
+USER_INCLUDE_DIR := $(OCERA_USER_INCLUDES_DIR)
+USER_LIB_DIR := $(OCERA_USER_LIBRARIES_DIR)
+USER_UTILS_DIR := $(TARGET_DIR)/usr/bin
+USER_BIN_DIR := $(TARGET_DIR)/usr/bin
+USER_BUILD_DIR := $(BUILD_DIR)/user/$(GROUP_DIR_NAME)
+#LINUX_DIR := $(OCERA_DIR)/kernel/linux
+#RTL_DIR := $(OCERA_DIR)/kernel/rtlinux
+#CONFIG_FILE := $(OCERA_DIR)/emdebsys/.config
+ifneq ($(wildcard $(CONFIG_FILE)),)
+CONFIG_FILE_OK = y
+endif
+else # OCERA_DIR
+KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
+KERN_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
+KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
+KERN_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
+KERN_MODPOST_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern-modpost
+USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
+USER_LIB_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
+USER_UTILS_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
+USER_BIN_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
+USER_BUILD_DIR := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
+
+ifndef LINUX_VERSION
+LINUX_VERSION=$(shell uname -r)
+endif
+ifndef LINUX_DIR
+LINUX_DIR=/lib/modules/$(LINUX_VERSION)/build
+endif
+endif # OCERA_DIR
+
+LOCAL_BUILD_DIR = $(USER_OBJS_DIR)
+
+# Local Variables:
+# mode:makefile
+# End:
+ #OMK@base
+# We need to ensure definition of sources directory first
+ifndef SOURCES_DIR
+SOURCES_DIR := $(shell ( pwd -L ) )
+endif
+
+.PHONY: all default check-make-ver
+
+all: check-make-ver default
+ @echo "Compilation finished"
+
+#=========================
+# Include the config file
+
+ifneq ($(CONFIG_FILE_OK),y)
+ifndef CONFIG_FILE
+CONFIG_FILE := $(MAKERULES_DIR)/config.omk
+endif
+ifneq ($(wildcard $(CONFIG_FILE)-default),)
+-include $(CONFIG_FILE)-default
+else
+ifneq ($(MAKECMDGOALS),default-config)
+$(warning Please, run "make default-config" first)
+endif
+endif
+
+ifneq ($(wildcard $(CONFIG_FILE)),)
+include $(CONFIG_FILE)
+CONFIG_FILE_OK = y
+endif
+endif #$(CONFIG_FILE_OK)
+
+export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR
+export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
+# OMK_SERIALIZE_INCLUDED has to be exported to submakes because passes
+# must to be serialized only in the toplevel make.
+
+ifndef RELATIVE_DIR
+RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%)
+endif
+override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
+override RELATIVE_DIR := $(RELATIVE_DIR:\\%=%)
+#$(warning RELATIVE_DIR $(RELATIVE_DIR))
+override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | sed -e 's_//_/_g' -e 's_/\./_/_g' -e 's_^\./__g' -e 's_\([^/][^/]*\)_.._g' -e 's_/$$__')
+#$(warning BACK2TOP_DIR $(BACK2TOP_DIR))
+
+#$(warning SOURCES_DIR = $(SOURCES_DIR))
+#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
+#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+# Defines for quiet compilation
+ifdef V
+ ifeq ("$(origin V)", "command line")
+ OMK_VERBOSE = $(V)
+ endif
+endif
+ifndef OMK_VERBOSE
+ OMK_VERBOSE = 0
+endif
+ifeq ($(OMK_VERBOSE),1)
+ Q =
+else
+ Q = @
+endif
+ifneq ($(findstring s,$(MAKEFLAGS)),)
+ QUIET_CMD_ECHO = true
+ OMK_SILENT = 1
+else
+ QUIET_CMD_ECHO = echo
+endif
+
+# ===================================================================
+# We have set up all important variables, so we can check and include
+# real OCERA style Makefile.omk now
+ifndef OMK_INCLUDED
+include $(SOURCES_DIR)/Makefile.omk
+OMK_INCLUDED := 1
+endif
+
+
+check-make-ver:
+ @GOOD_MAKE_VERSION=`echo $(MAKE_VERSION) | sed -n -e 's/^[4-9]\..*\|^3\.9[0-9].*\|^3\.8[1-9].*/y/p'` ; \
+ if [ x$$GOOD_MAKE_VERSION != xy ] ; then \
+ echo "Your make program version is too old and does not support OMK system." ; \
+ echo "Please update to make program 3.81beta1 or newer." ; exit 1 ; \
+ fi
+
+distclean dist-clean:
+ @$(QUIET_CMD_ECHO) " RM $(COMPILED_DIR_NAME) $(BUILD_DIR_NAME)"
+ @rm -fr $(MAKERULES_DIR)/$(COMPILED_DIR_NAME) $(MAKERULES_DIR)/$(BUILD_DIR_NAME)
+
+# Common OMK templates
+# ====================
+
+# Syntax: $(call mkdir,<dir name>)
+define mkdir_def
+ [ -d $(1) ] || mkdir -p $(1) || exit 1
+endef
+
+ifneq ($(V),2)
+NO_PRINT_DIRECTORY := --no-print-directory
+endif
+
+# Syntax: $(call omk_pass_template,<pass name>,<build dir>,[<local make flags>],[<local condition>])
+define omk_pass_template
+.PHNOY: $(1) $(1)-local
+$(1):
+ +@$(foreach dir,$(SUBDIRS),$(call mkdir_def,$(2)/$(dir)); \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) $(NO_PRINT_DIRECTORY) \
+ RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(2)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile $$@ || exit 1 ;) true
+ifneq ($(4),)
+ @echo "make[omk]: $$@ in $(RELATIVE_DIR)"; \
+ $(call mkdir_def,$(2)); \
+ $(MAKE) $(NO_PRINT_DIRECTORY) -C $(2) \
+ -f $(SOURCES_DIR)/Makefile $(3) $$(@:%=%-local)
+endif
+endef
+
+# =======================
+# DEFAULT CONFIG PASS
+
+default-config:
+ @echo "# Start of OMK config file" > "$(CONFIG_FILE)-default"
+ @echo "# This file should not be altered manually" >> "$(CONFIG_FILE)-default"
+ @echo "# Overrides should be stored in file $(notdir $(CONFIG_FILE))" >> "$(CONFIG_FILE)-default"
+ @echo >> "$(CONFIG_FILE)-default"
+ @$(MAKE) $(NO_PRINT_DIRECTORY) -C $(MAKERULES_DIR) \
+ RELATIVE_DIR="" SOURCES_DIR=$(MAKERULES_DIR) \
+ -f $(MAKERULES_DIR)/Makefile default-config-pass
+
+$(eval $(call omk_pass_template,default-config-pass,$$(LOCAL_BUILD_DIR),,always))
+
+default-config-pass-local:
+# @echo Default config for $(RELATIVE_DIR)
+ @echo "# Config for $(RELATIVE_DIR)" >> "$(CONFIG_FILE)-default"
+ @$(foreach x, $(default_CONFIG), echo $(x) | \
+ sed -e 's/^.*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
+ #OMK@config_h
+# Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
+define BUILD_CONFIG_H_template
+
+$(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+ @$(QUIET_CMD_ECHO) " CONFGEN $$(@:$(MAKERULES_DIR)/%=%)"
+ @if [ ! -d `dirname $(1).tmp` ] ; then \
+ mkdir `dirname $(1).tmp` ; fi
+ @echo "/* Automatically generated from */" > "$(1).tmp"
+ @echo "/* config file: $$< */" >> "$(1).tmp"
+ @echo "#ifndef $(3)" >> "$(1).tmp"
+ @echo "#define $(3)" >> "$(1).tmp"
+ @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \
+ echo '$(x).$($(x))' ; ) echo ; ) | \
+ sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
+ sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
+ >> "$(1).tmp"
+ @echo "#endif /*$(3)*/" >> "$(1).tmp"
+ @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp" ; \
+ else mv "$(1).tmp" "$(1)" ; \
+ echo Updated configuration "$(1)" ; fi
+
+endef
+
+ifdef LOCAL_CONFIG_H
+
+CFLAGS += -I.
+$(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
+
+endif
+
+# Special rules for configuration exported headers
+
+#FIXME: The directory for headers should not be specified here.
+$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
+_$(basename $(notdir $(confh)))_H \
+)))
+
+# Add some hooks to standard passes
+include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
+
+clean-local: clean-local-config-h
+
+clean-local-config-h:
+ @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
+ if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \
+ )
+
+
+# Local Variables:
+# mode:makefile
+# End:
+ifeq ($(OMK_VERBOSE),1) #OMK@include
+CPHEADER_FLAGS += -v
+LNHEADER_FLAGS += -v
+endif
+
+ifneq ($(LN_HEADERS),y)
+define cp_cmd
+( echo " CP $(1:$(MAKERULES_DIR)/%=%) -> $(2:$(MAKERULES_DIR)/%=%)"; cp $(CPHEADER_FLAGS) $(1) $(2) )
+endef
+else
+define cp_cmd
+( echo " LN $(1:$(MAKERULES_DIR)/%=%) -> $(2:$(MAKERULES_DIR)/%=%)"; ln -sf $(LNHEADER_FLAGS) $(1) $(2) )
+endef
+endif
+
+# TODO: Check modification date of changed header files. If it is
+# newer that in source dir, show a warning.
+
+# Syntax: $(call include-pass-template,<include dir>,<keyword>)
+define include-pass-template
+ @$(foreach f, $($(2)_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(1)/$(notdir $(f)) \
+ || $(call cp_cmd,$(SOURCES_DIR)/$(f),$(1)/$(notdir $(f))) || exit 1 ; )
+ @$(foreach f, $(nobase_$(2)_HEADERS), cmp --quiet $(SOURCES_DIR)/$(f) $(1)/$(f) \
+ || ( mkdir -p $(1)/$(dir $(f)) && $(call cp_cmd,$(SOURCES_DIR)/$(f),$(1)/$(f)) ) || exit 1 ; )
+ @$(foreach f, $(renamed_$(2)_HEADERS), \
+ srcfname=`echo '$(f)' | sed -e 's/^\(.*\)->.*$$/\1/'` ; destfname=`echo '$(f)' | sed -e 's/^.*->\(.*\)$$/\1/'` ; \
+ cmp --quiet $(SOURCES_DIR)/$${srcfname} $(1)/$${destfname} \
+ || ( mkdir -p `dirname $(1)/$${destfname}` && $(call cp_cmd,$(SOURCES_DIR)/$${srcfname},$(1)/$${destfname}) ) || exit 1 ; )
+endef
+
+# Local Variables:
+# mode:makefile
+# End:
+ #OMK@linux
+# Hack to check RT-Linux rules
+#LINUX_DIR := /home/cvs/ocera/ocera-build/kernel/linux
+#RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
+#CONFIG_RTLINUX = y
+#OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
+
+#CFLAGS += -ggdb
+#CFLAGS += -O2
+CFLAGS += -Wall
+#CXXFLAGS += -ggdb
+CXXFLAGS += -O2
+CXXFLAGS += -Wall
+
+
+CPPFLAGS += -I $(USER_INCLUDE_DIR)
+
+LOADLIBES += -L$(USER_LIB_DIR)
+
+LOADLIBES += $(lib_LOADLIBES:%=-l%)
+
+LIB_CPPFLAGS += $(CPPFLAGS)
+LIB_CFLAGS += $(CFLAGS)
+
+ifeq ($(TARGET_OS),win32)
+ SOLIB_EXT = dll
+else
+ SOLIB_EXT = so
+ SOLIB_PICFLAGS += -fpic
+endif
+
+ifndef RELATIVE_DIR
+RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%)
+endif
+override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
+override RELATIVE_DIR := $(RELATIVE_DIR:\\%=%)
+#$(warning RELATIVE_DIR $(RELATIVE_DIR))
+override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | sed -e 's_//_/_g' -e 's_/\./_/_g' -e 's_^\./__g' -e 's_\([^/][^/]*\)_.._g' -e 's_/$$__')
+#$(warning BACK2TOP_DIR $(BACK2TOP_DIR))
+
+#$(warning SOURCES_DIR = $(SOURCES_DIR))
+#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
+#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+
+override RELATIVE_PREFIX := $(RELATIVE_DIR)/
+override RELATIVE_PREFIX := $(RELATIVE_PREFIX:/%=%)
+
+#vpath %.c $(SOURCES_DIR)
+#vpath %.cc $(SOURCES_DIR)
+#vpath %.cxx $(SOURCES_DIR)
+
+VPATH = $(SOURCES_DIR)
+srcdir = $(SOURCES_DIR)
+
+USER_OBJS_DIR = $(USER_BUILD_DIR)/$(RELATIVE_DIR)
+KERN_OBJS_DIR = $(KERN_BUILD_DIR)/$(RELATIVE_DIR)
+
+.PHONY: dep subdirs clean clean-custom cleandepend
+
+# Some support to serialize some targets for parallel make
+ifneq ($(OMK_SERIALIZE_INCLUDED),y)
+include-pass: $(check-dir)
+library-pass: include-pass
+binary-pass: library-pass
+kernel-lib-pass: include-pass
+kernel-mod-pass: kernel-lib-pass
+kernel-modpost-pass: kernel-mod-pass
+kernel-pass: kernel-mod-pass kernel-modpost-pass
+
+OMK_SERIALIZE_INCLUDED = y
+endif
+
+#=====================================================================
+# User-space rules and templates to compile programs, libraries etc.
+
+ifdef USER_RULE_TEMPLATES
+
+ifdef CPP_ONLY
+OBJ_EXT := .E
+CC_STAGE_STOP := E
+else
+OBJ_EXT := .o
+CC_STAGE_STOP := c
+endif
+
+USER_SOURCES2OBJS = $(OBJ_EXT)/.c $(OBJ_EXT)/.cc $(OBJ_EXT)/.cxx $(OBJ_EXT)/$(OBJ_EXT)
+
+USER_SOURCES2OBJSLO = .lo/.c .lo/.cc .lo/.cxx .lo/.lo
+
+#%.lo: %.c
+# $(CC) -o $@ $(LCFLAGS) -c $<
+
+c_o_COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+cc_o_COMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DOMK_FOR_USER
+
+idl_COMPILE = $(IDL_COMPILER)
+
+# Check GCC version for user build
+ifndef CC_MAJOR_VERSION
+CC_MAJOR_VERSION := $(shell $(CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(CC_MAJOR_VERSION),2)
+CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+
+# Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_c_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " CC $$@"
+ $(Q) if $$(c_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -$(CC_STAGE_STOP) $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+# Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_cc_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " CXX $$@"
+ $(Q) if $$(cc_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -$(CC_STAGE_STOP) $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+# Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
+define COMPILE_S_o_template
+$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+ @$(QUIET_CMD_ECHO) " AS $$@"
+ $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -$(CC_STAGE_STOP) $$< ; \
+ then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
+define CMETRIC_o_h_template
+$(2): $(1)
+ @$(QUIET_CMD_ECHO) " CMETRIC $$@"
+ $(Q)if [ -n `dirname $$@` ] ; then \
+ if [ ! -e `dirname $$@` ] ; then \
+ mkdir -p `dirname $$@` ; fi ; fi
+ $(Q)echo >$$@ '/* Automatically generated from $$< */'
+ $(Q)echo >>$$@ '/* Conditionals to control compilation */'
+ $(Q)set -o pipefail ; $(NM) $$< \
+ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
+ | sort >>$$@
+ $(Q)echo >>$$@ '/* Defines from the values defined to symbols */'
+ $(Q)set -o pipefail ; $(NM) $$< \
+ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
+ | sort >>$$@
+endef
+
+
+
+define COMPILE_idl_template
+$(2).c $(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1)
+ @$(QUIET_CMD_ECHO) " IDL $$@"
+ $(Q) $$(idl_COMPILE) $(1)
+endef
+
+
+# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<executable-suffix>,<linker-sript>)
+# FIXME: ???????? asi je tu blbej komentar
+define PROGRAM_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+USER_GEN_SOURCES += $$($(1)_GEN_SOURCES)
+
+$(foreach x, $(USER_SOURCES2OBJS),
+$(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
+ $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
+)
+$(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(2)/$(1): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES:%.cxx=%.cc))" ] ; then echo $$(CC) ; else echo $$(CXX) ; fi) \
+ $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(LDFLAGS) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $(2)/$(1)
+ @echo "$(2)/$(1): \\" >$(USER_OBJS_DIR)/$(1).exe.d
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(USER_OBJS_DIR)/$(1).exe.map >>$(USER_OBJS_DIR)/$(1).exe.d
+ @echo >>$(USER_OBJS_DIR)/$(1).exe.d
+endef
+
+
+# Syntax: $(call LIBRARY_template,<library-name>)
+define LIBRARY_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+USER_GEN_SOURCES += $$($(1)_GEN_SOURCES)
+
+$(foreach x, $(USER_SOURCES2OBJS),
+$(1)_OBJS += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
+ $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
+)
+$(1)_OBJS := $$(sort $$($(1)_OBJS:%/=%))
+
+USER_OBJS += $$($(1)_OBJS)
+USER_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR $$@"
+ $(Q) $(AR) rcs $$@ $$^
+endef
+
+
+# Syntax: $(call SOLIB_template,<library-name>)
+define SOLIB_template
+
+USER_IDLS += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-stubs.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_CLIENT_IDL:%.idl=%-common.c))
+$(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_IDL:%.idl=%.c))
+SOLIB_GEN_SOURCES += $$($(1)_GEN_SOURCES)
+
+$(foreach x, $(USER_SOURCES2OBJSLO),
+$(1)_OBJSLO += $$(patsubst %$(notdir $(x)),%$(dir $(x)),$$(filter %$(notdir $(x)),\
+ $$($(1)_SOURCES) $$($(1)_GEN_SOURCES)))
+)
+$(1)_OBJSLO := $$(sort $$($(1)_OBJSLO:%/=%))
+
+SOLIB_OBJS += $$($(1)_OBJSLO)
+SOLIB_SOURCES += $$($(1)_SOURCES)
+
+$(USER_LIB_DIR)/lib$(1).$(SOLIB_EXT): $$($(1)_OBJSLO)
+ @$(QUIET_CMD_ECHO) " LINK $$@"
+ $(Q) $(LD) --shared --soname=lib$(1).$(SOLIB_EXT) -o $$@ $$^
+endef
+
+
+
+library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
+ $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.$(SOLIB_EXT))
+
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%)
+
+# Special rules for CMETRIC generated headers
+
+$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call COMPILE_c_o_template,\
+ $(SOURCES_DIR)/$($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES),\
+ $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%$(OBJ_EXT)),)))
+$(foreach cmetrh,$(cmetric_include_HEADERS),$(eval $(call CMETRIC_o_h_template,\
+ $($(basename $(notdir $(cmetrh)))_CMETRIC_SOURCES:%.c=%$(OBJ_EXT)),\
+ $(addprefix $(USER_INCLUDE_DIR)/,$(cmetrh)))))
+
+GEN_HEADERS+=$(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%)
+
+GEN_HEADERS+=$(filter %.h,$(USER_IDLS:%.idl=%.h))
+
+# Generate rules for compilation of programs and libraries
+
+$(foreach prog,$(utils_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_UTILS_DIR))))
+
+$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+
+$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
+
+$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
+
+-include $(USER_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+# Kernel-space rules and templates to compile modules, libraries etc.
+
+ifdef KERN_RULE_TEMPLATES
+
+$(KERN_LIB_DIR)/kernel.mk: $(LINUX_DIR)/.config $(MAKERULES_DIR)/kernelcfg2mk
+ @$(QUIET_CMD_ECHO) " KCFG2MK $$@"
+ $(Q) $(MAKERULES_DIR)/kernelcfg2mk $(LINUX_DIR) $(KERN_LIB_DIR)
+
+ifeq ($(CONFIG_RTLINUX),y)
+include $(RTL_DIR)/rtl.mk
+
+KERN_CC = $(CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+INCLUDES := -I $(KERN_INCLUDE_DIR) $(INCLUDE) $(rtlinux_INCLUDES) $(kernel_INCLUDES)
+#-DEXPORT_NO_SYMBOLS
+c_o_kern_COMPILE = $(KERN_CC) -idirafter $(kern_GCCLIB_DIR)/include $(INCLUDES) $(CFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := .o
+KERN_ARCH = $(ARCH)
+KERN_LD = $(LD)
+KERN_AR = $(AR)
+
+else # CONFIG_RTLINUX
+
+include $(KERN_LIB_DIR)/kernel.mk
+
+ifeq ($(LINUX_SRC),)
+LINUX_SRC = $(LINUX_DIR)
+endif
+kernel_INCLUDES += -I $(LINUX_DIR) -idirafter $(LINUX_SRC)/include/linux
+
+ifdef LINUX_CC
+KERN_CC = $(LINUX_CC)
+kern_GCCLIB_DIR=$(shell LANG=C LC_ALL=C LC_MESSAGES=C $(LINUX_CC) -print-search-dirs | sed -n -e 's/^install: \(.*\)$$/\1/p' )
+else
+KERN_CC = echo KERN_CC not defined - compilation skipped
+endif
+c_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB -nostdinc
+cc_o_kern_COMPILE = $(KERN_CC) $(kernel_INCLUDES) -idirafter $(kern_GCCLIB_DIR)/include $(LINUX_CPPFLAGS) $(LINUX_CFLAGS) $(LINUX_CFLAGS_MODULE) -DOMK_FOR_KERNEL -DEXPORT_SYMTAB
+KERN_EXE_SUFFIX := $(LINUX_MODULE_EXT)
+KERN_LDFLAGS = $(LINUX_LDFLAGS)
+ifdef LINUX_ARCH
+KERN_ARCH = $(LINUX_ARCH)
+else
+KERN_ARCH = echo KERN_ARCH not defined - skipped
+endif
+ifdef LINUX_LD
+KERN_LD = $(LINUX_LD)
+else
+KERN_LD = echo KERN_LD not defined - skipped
+endif
+ifneq ($(LINUX_AR),)
+KERN_AR = $(LINUX_AR)
+else
+KERN_AR = $(AR)
+endif
+ifeq ($(LINUX_QUOTE_MODNAME),y)
+KERN_MQ=\"
+endif
+endif # CONFIG_RTLINUX
+
+KERN_LOADLIBES += -L$(KERN_LIB_DIR)
+
+KERN_LOADLIBES += $(rtlinux_LOADLIBES:%=-l%)
+KERN_LOADLIBES += $(kernel_LOADLIBES:%=-l%)
+
+
+
+# Check GCC version for kernel part of build
+ifndef kern_CC_MAJOR_VERSION
+kern_CC_MAJOR_VERSION := $(shell $(KERN_CC) -dumpversion | sed -e 's/\([^.]\)\..*/\1/')
+endif
+# Prepare suitable define for dependency building
+ifeq ($(kern_CC_MAJOR_VERSION),2)
+kern_CC_DEPFLAGS = -Wp,-MD,"$@.d.tmp"
+else
+kern_CC_DEPFLAGS = -MT $@ -MD -MP -MF "$@.d.tmp"
+endif
+
+ifeq ($(KERN_EXE_SUFFIX),.ko)
+ifeq ($(wildcard $(LINUX_DIR)/scripts/mod/modpost),)
+KERN_MODPOST = $(LINUX_DIR)/scripts/modpost
+else
+KERN_MODPOST = $(LINUX_DIR)/scripts/mod/modpost
+endif
+KERN_MODULES_LINK_DIR = $(KERN_MODPOST_DIR)
+KERN_LINK_SUFFIX = .o
+else
+KERN_MODULES_LINK_DIR = $(KERN_MODULES_DIR)
+KERN_LINK_SUFFIX = $(KERN_EXE_SUFFIX)
+endif
+
+define COMPILE_c_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CC [K] $$@"
+ $(Q) if $$(c_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -D"KBUILD_BASENAME=$(KERN_MQ)$(notdir $(basename $(1)))$(KERN_MQ)" \
+ -o $$@ -$(CC_STAGE_STOP) $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define COMPILE_cc_o_kern_template
+
+$(2): $(1) $(LOCAL_CONFIG_H)
+ @$(QUIET_CMD_ECHO) " CXX [K] $$@"
+ $(Q) if $$(cc_o_kern_COMPILE) $$(kern_CC_DEPFLAGS) $(3) -D"KBUILD_BASENAME=$(KERN_MQ)$(notdir $(basename $(1)))$(KERN_MQ)" \
+ -o $$@ -$(CC_STAGE_STOP) $$< ; \
+ then mv -f "$$@.d.tmp" "$$@.d" ; \
+ else rm -f "$$@.d.tmp" ; exit 1; \
+ fi
+endef
+
+
+
+define MODULE_kern_template
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o))
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+# this is hack to build "__this_module" structure for 2.6.x kernels
+# modpost is used for that purpose now
+
+#$(1).mod.c:
+# echo "\
+# #include <linux/version.h>@\
+# #include <linux/module.h>@\
+# #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5))@\
+# #include <linux/vermagic.h>@\
+# #include <linux/compiler.h>@\
+# @\
+# MODULE_INFO(vermagic, VERMAGIC_STRING);@\
+# @\
+# #undef unix@\
+# struct module __this_module@\
+# __attribute__((section(\".gnu.linkonce.this_module\"))) = {@\
+# .name = __stringify(KBUILD_MODNAME),@\
+# .init = init_module,@\
+# #ifdef CONFIG_MODULE_UNLOAD@\
+# .exit = cleanup_module,@\
+# #endif@\
+# };@\
+# #endif@\
+# " | tr @ \\n >$$@
+
+
+#$(eval $(call COMPILE_c_o_kern_template,$(1).mod.c,$(1).mod.o,-DKBUILD_MODNAME=$(1)))
+
+$(2)/$(1)$(KERN_LINK_SUFFIX): $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " LD [K] $$@"
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) -r $$($(1)_OBJS) -L$$(kern_GCCLIB_DIR) $$($(1)_LIBS:%=-l%) $$(KERN_LOADLIBES) -Map $(KERN_OBJS_DIR)/$(1).mod.map -o $$@
+ @echo "$(2)/$(1)$(KERN_LINK_SUFFIX): \\" >$(KERN_OBJS_DIR)/$(1).mod.d
+ @sed -n -e 's/^LOAD \(.*\)$$$$/ \1 \\/p' $(KERN_OBJS_DIR)/$(1).mod.map >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @echo >>$(KERN_OBJS_DIR)/$(1).mod.d
+ @if [ "$(KERN_EXE_SUFFIX)" == ".ko" ] ; then \
+ echo $(1) >>$(KERN_MODPOST_DIR)/module-changes ; \
+ echo $(1) >>$(KERN_MODPOST_DIR)/$(1).mod.stamp ; \
+ fi
+
+endef
+
+
+
+define LIBRARY_kern_template
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.c=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cc=%.o))
+$(1)_OBJS += $$(filter %.o,$$($(1)_SOURCES:%.cxx=%.o))
+$(1)_OBJS := $$(sort $$($(1)_OBJS))
+
+KERN_OBJS += $$($(1)_OBJS)
+KERN_SOURCES += $$($(1)_SOURCES)
+
+$(KERN_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
+ @$(QUIET_CMD_ECHO) " AR [K] $$@"
+ $(Q) $(KERN_AR) rcs $$@ $$^
+endef
+
+
+ifdef LINUX_DIR
+
+kernel-lib-pass-local: $(kernel_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+kernel-mod-pass-local: $(kernel_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+$(foreach module,$(kernel_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(kernel_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+
+ifeq ($(CONFIG_RTLINUX),y)
+
+kernel-mod-pass-local: $(rtlinux_MODULES:%=$(KERN_MODULES_LINK_DIR)/%$(KERN_LINK_SUFFIX))
+
+kernel-lib-pass-local: $(rtlinux_LIBRARIES:%=$(KERN_LIB_DIR)/lib%.a)
+
+$(foreach module,$(rtlinux_MODULES),$(eval $(call MODULE_kern_template,$(module),$(KERN_MODULES_LINK_DIR))))
+
+$(foreach lib,$(rtlinux_LIBRARIES),$(eval $(call LIBRARY_kern_template,$(lib))))
+
+endif
+
+ifeq ($(KERN_MODPOST_PASS),y)
+
+MODULES_LIST := $(wildcard *.mod.stamp)
+MODULES_LIST := $(MODULES_LIST:%.mod.stamp=%)
+
+define MODPOST_kern_template
+$(2) : $(1)$(KERN_LINK_SUFFIX) $(1).mod.c
+ @$(QUIET_CMD_ECHO) " LD [M] $$@"
+ $(Q) $$(cc_o_kern_COMPILE) -D"KBUILD_BASENAME=$(KERN_MQ)$(1)$(KERN_MQ)" \
+ -D"KBUILD_MODNAME=$(KERN_MQ)$(1)$(KERN_MQ)" \
+ -o $(1).mod.o -c $(1).mod.c
+ $(Q) $$(KERN_LD) $$(KERN_LDFLAGS) $(1)$(KERN_LINK_SUFFIX) $(1).mod.o -r -o $$@
+endef
+
+kernel-modpost-versions: $(wildcard $(LINUX_DIR)/Module.symvers)
+ @$(QUIET_CMD_ECHO) " MODPOST $(KERN_MODPOST_DIR)"
+ @echo >$(KERN_MODPOST_DIR)/modpost-running
+ @rm -f $(KERN_MODPOST_DIR)/module-changes
+ $(Q) $(KERN_MODPOST) $(MODULES_LIST:%=%$(KERN_LINK_SUFFIX)) $(^:%=-i %)
+
+$(MODULES_LIST:%=%.mod.c) : kernel-modpost-versions
+
+kernel-modpost-pass-local: $(MODULES_LIST:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX))
+ @rm -f $(KERN_MODPOST_DIR)/modpost-running
+
+$(foreach module,$(MODULES_LIST),$(eval $(call MODPOST_kern_template,$(module),$(module:%=$(KERN_MODULES_DIR)/%$(KERN_EXE_SUFFIX)))))
+
+endif
+
+-include $(KERN_OBJS_DIR)/*.d
+
+endif
+
+#=====================================================================
+
+$(eval $(call omk_pass_template, kernel-lib-pass,$(KERN_OBJS_DIR),KERN_RULE_TEMPLATES=y,$(kernel_LIBRARIES)$(rtlinux_LIBRARIES)))
+$(eval $(call omk_pass_template, kernel-mod-pass,$(KERN_OBJS_DIR),KERN_RULE_TEMPLATES=y,$(kernel_MODULES)$(rtlinux_MODULES)))
+
+kernel-modpost-pass:
+ +@if [ -e "$(KERN_MODPOST_DIR)/module-changes" -o -e "$(KERN_MODPOST_DIR)/modpost-running" ] ; \
+ then \
+ $(MAKE) --no-print-directory -C $(KERN_MODPOST_DIR) \
+ -f $(SOURCES_DIR)/Makefile KERN_RULE_TEMPLATES=y KERN_MODPOST_PASS=y $(@:%=%-local) ; \
+ fi
+
+$(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)))
+$(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)))
+
+OTHER_PASSES = clean install include-pass
+$(eval $(call omk_pass_template,$(OTHER_PASSES),$(USER_OBJS_DIR),,always))
+
+# Create directories only for the first time
+ifndef CHECK_DIR_DONE
+check-dir = check-dir
+CHECK_DIR_DONE = y
+endif
+export CHECK_DIR_DONE
+
+check-dir:
+ @$(call mkdir_def,$(USER_BUILD_DIR))
+ @$(call mkdir_def,$(KERN_BUILD_DIR))
+ @$(call mkdir_def,$(USER_INCLUDE_DIR))
+ @$(call mkdir_def,$(KERN_INCLUDE_DIR))
+ @$(call mkdir_def,$(USER_LIB_DIR))
+ @$(call mkdir_def,$(KERN_LIB_DIR))
+ @$(call mkdir_def,$(USER_BIN_DIR))
+ @$(call mkdir_def,$(USER_UTILS_DIR))
+ @$(call mkdir_def,$(KERN_MODULES_DIR))
+ @$(call mkdir_def,$(KERN_MODPOST_DIR))
+
+install-local: # TODO
+
+include-pass-local:
+ $(call include-pass-template,$(USER_INCLUDE_DIR),include)
+ $(call include-pass-template,$(KERN_INCLUDE_DIR),kernel)
+
+ifdef USER_RULE_TEMPLATES
+
+# User-space static libraries and applications object files
+
+USER_SOURCES := $(sort $(USER_SOURCES))
+
+USER_GEN_SOURCES := $(sort $(USER_GEN_SOURCES))
+
+#$(warning USER_SOURCES = $(USER_SOURCES))
+
+$(foreach src,$(filter %.c,$(USER_SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%$(OBJ_EXT)),)))
+
+$(foreach src,$(filter %.cc,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%$(OBJ_EXT)),)))
+
+$(foreach src,$(filter %.cxx,$(USER_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%$(OBJ_EXT)),)))
+
+$(foreach src,$(filter %.c,$(USER_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%$(OBJ_EXT)),)))
+
+# User-space shared libraries object files
+
+SOLIB_SOURCES := $(sort $(SOLIB_SOURCES))
+
+SOLIB_GEN_SOURCES := $(sort $(SOLIB_GEN_SOURCES))
+
+#$(warning SOLIB_SOURCES = $(SOLIB_SOURCES))
+#$(warning SOLIB_GEN_SOURCES = $(SOLIB_GEN_SOURCES))
+
+$(foreach src,$(filter %.c,$(SOLIB_SOURCES)),$(eval $(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach src,$(filter %.cc,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach src,$(filter %.cxx,$(SOLIB_SOURCES)),$(eval $(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%.lo),$(SOLIB_PICFLAGS))))
+
+$(foreach src,$(filter %.c,$(SOLIB_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS))))
+
+# IDL compilation
+
+USER_IDLS := $(sort $(USER_IDLS))
+
+$(foreach src,$(filter %.idl,$(USER_IDLS)),$(eval $(call COMPILE_idl_template,$(SOURCES_DIR)/$(src),$(src:%.idl=%))))
+
+endif
+
+ifdef KERN_RULE_TEMPLATES
+
+KERN_SOURCES := $(sort $(KERN_SOURCES))
+
+#$(warning KERN_SOURCES = $(KERN_SOURCES))
+
+$(foreach src,$(filter %.c,$(KERN_SOURCES)),$(eval $(call COMPILE_c_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.c=%$(OBJ_EXT)),)))
+
+$(foreach src,$(filter %.cc,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%$(OBJ_EXT)),)))
+
+$(foreach src,$(filter %.cxx,$(KERN_SOURCES)),$(eval $(call COMPILE_cc_o_kern_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%$(OBJ_EXT)),)))
+
+endif
+
+clean-local: clean-custom
+ @echo Cleaning in $(KERN_OBJS_DIR) and $(USER_OBJS_DIR)
+ @rm -f $(KERN_OBJS_DIR)/*$(OBJ_EXT) $(USER_OBJS_DIR)/*$(OBJ_EXT) $(USER_OBJS_DIR)/*.lo \
+ $(KERN_OBJS_DIR)/*.d $(USER_OBJS_DIR)/*.d \
+ $(KERN_OBJS_DIR)/*.map $(USER_OBJS_DIR)/*.map \
+ $(KERN_OBJS_DIR)/*.mod.c \
+ $(kernel_MODULES:%=$(KERN_MODPOST_DIR)/%.*) \
+ $(LOCAL_CONFIG_H:%=$(KERN_OBJS_DIR)/%) \
+ $(LOCAL_CONFIG_H:%=$(USER_OBJS_DIR)/%)
+ @if [ -e $(KERN_LIB_DIR)/kernel.mk ] ; then \
+ touch -t 200001010101 $(KERN_LIB_DIR)/kernel.mk ; \
+ fi
+
+default: $(check-dir) include-pass library-pass binary-pass
+ifndef OMIT_KERNEL_PASSES
+# Also make kernel passes if not disabled
+default: kernel-lib-pass kernel-pass
+endif
+
+# Local Variables:
+# mode:makefile
+# End:
+ #OMK@qt
+ifneq ($(QT_SUBDIRS),)
+
+.PHONY: qt-subpass
+qt-subpass:
+ +@$(foreach dir, $(QT_SUBDIRS), $(call mkdir_def,$(USER_OBJS_DIR)/$(dir)) ; \
+ if [ ! -e $(SOURCES_DIR)/$(dir)/Makefile ] ; then \
+ ( cd $(SOURCES_DIR)/$(dir) ; $(QTDIR:%=%/bin/)qmake TOP_DIR=$(MAKERULES_DIR) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) $(QTDIR:%=QTDIR=%) CC=$(CC) \
+ CXX=$(CXX) || exit 1 ;) ; fi ; \
+ $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
+ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(SOURCES_DIR)/$(dir) \
+ -f $(SOURCES_DIR)/$(dir)/Makefile || exit 1 ;)
+
+# Hook to binary pass
+binary-pass: qt-subpass
+
+endif
+
+# Local Variables:
+# mode:makefile
+# End:
+ #OMK@sources-list
+# Rules that creates the list of files which are used during
+# compilation. The list reflects conditional compilation depending on
+# config.omk and other variables.
+
+SOURCES_LIST_FN=sources.txt
+ifndef SOURCES_LIST
+SOURCES_LIST_DIR:=$(RELATIVE_DIR)
+SOURCES_LIST:=$(MAKERULES_DIR)/$(SOURCES_LIST_DIR)/$(SOURCES_LIST_FN)
+export SOURCES_LIST SOURCES_LIST_DIR
+endif
+
+ifeq ($(MAKECMDGOALS),sources-list)
+NEED_SOURCES_LIST=y
+endif
+ifeq ($(MAKECMDGOALS),TAGS)
+NEED_SOURCES_LIST=y
+endif
+ifeq ($(MAKECMDGOALS),tags)
+NEED_SOURCES_LIST=y
+endif
+
+ifeq ($(NEED_SOURCES_LIST),y) # avoid execution of find command bellow if it is not useful
+.PHONY: sources-list
+sources-list: $(SOURCES_LIST)
+
+$(SOURCES_LIST): $(CONFIG_FILE) $(CONFIG_FILE)-default $(shell find -name Makefile.omk)
+ @echo -n "" > "$(SOURCES_LIST).tmp"
+ @$(MAKE) --no-print-directory sources-list-pass
+ @echo "# Automatically generated list of files in '$(RELATIVE_DIR)' that are used during OMK compilation" > "$(SOURCES_LIST).tmp2"
+ @cat "$(SOURCES_LIST).tmp"|sort|uniq >> "$(SOURCES_LIST).tmp2"
+ @rm "$(SOURCES_LIST).tmp"
+ @mv "$(SOURCES_LIST).tmp2" "$(SOURCES_LIST)"
+endif
+
+$(eval $(call omk_pass_template,sources-list-pass,$$(LOCAL_BUILD_DIR),,always))
+
+sources-list-pass-local:
+ @$(foreach h,$(include_HEADERS) $(nobase_include_HEADERS) $(kernel_HEADERS),\
+ echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)" >> "$(SOURCES_LIST).tmp";)
+ @$(foreach h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
+ @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(utils_PROGRAMS) \
+ $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
+ $(foreach src,$(filter-out %.o,$($(bin)_SOURCES)),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(src)" >> "$(SOURCES_LIST).tmp";))
+
+############ TAGS ###########
+
+ifeq ($(MAKECMDGOALS),TAGS)
+ETAGS=etags
+TAGS_CMD = $(ETAGS)
+endif
+ifeq ($(MAKECMDGOALS),tags)
+CTAGS=ctags -N
+TAGS_CMD = $(CTAGS)
+endif
+export TAGS_CMD
+
+tags TAGS: $(SOURCES_LIST)
+ @$(MAKE) --no-print-directory do-tags
+
+ifeq ($(MAKECMDGOALS),do-tags)
+.PHONY: do-tags
+do-tags: $(shell sed -e '/^\#/d' $(SOURCES_LIST))
+ @$(QUIET_CMD_ECHO) " TAGS $(SOURCES_LIST_FN)"
+ $(Q)$(TAGS_CMD) $^
+endif
+
+############ CSCOPE ###########
+
+cscope: $(SOURCES_LIST)
+ @$(QUIET_CMD_ECHO) " CSCOPE < $(SOURCES_LIST_FN)"
+ $(Q)sed -e '/^#/d' $(SOURCES_LIST)|cscope -b -i-
+#FIXME: see doc to -i in cscope(1)
+
+# Local Variables:
+# mode:makefile
+# End:
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+bin_PROGRAMS = test
+test_SOURCES = test.c
+test_LIBS = bluetooth mirobt
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <bth_fce_out.h>
+#include <bth_inface.h>
+#include <stdio.h>
+
+/* #include <cmd_proc.h> */
+/* #include "cmd_bth.h" */
+/* #include "cmd_pxmc.h" */
+#include <bth_h8s2638.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+static int open_socket(int dev, unsigned long flags)
+{
+ struct sockaddr_hci addr;
+ struct hci_filter flt;
+ struct hci_dev_info di;
+ int sk, dd, opt;
+
+ if (dev != HCI_DEV_NONE) {
+ dd = hci_open_dev(dev);
+ if (dd < 0) {
+ perror("Can't open device");
+ exit(1);
+ }
+
+ if (hci_devinfo(dev, &di) < 0) {
+ perror("Can't get device info");
+ exit(1);
+ }
+
+ opt = hci_test_bit(HCI_RAW, &di.flags);
+ if (ioctl(dd, HCISETRAW, opt) < 0) {
+ if (errno == EACCES) {
+ perror("Can't access device");
+ exit(1);
+ }
+ }
+
+ hci_close_dev(dd);
+ }
+
+ /* Create HCI socket */
+ sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+ if (sk < 0) {
+ perror("Can't create raw socket");
+ exit(1);
+ }
+
+ opt = 1;
+ if (setsockopt(sk, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
+ perror("Can't enable data direction info");
+ exit(1);
+ }
+
+ opt = 1;
+ if (setsockopt(sk, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
+ perror("Can't enable time stamp");
+ exit(1);
+ }
+
+ /* Setup filter */
+ hci_filter_clear(&flt);
+ hci_filter_all_ptypes(&flt);
+ hci_filter_all_events(&flt);
+ if (setsockopt(sk, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
+ perror("Can't set filter");
+ exit(1);
+ }
+
+ /* Bind socket to the HCI device */
+ addr.hci_family = AF_BLUETOOTH;
+ addr.hci_dev = dev;
+ if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ printf("Can't attach to device hci%d. %s(%d)\n",
+ dev, strerror(errno), errno);
+ exit(1);
+ }
+
+ return sk;
+}
+
+
+int main()
+{
+ int zn_bth;
+
+ printf("I'm here\n");
+
+ extern int hci_socket;
+ //hci_socket = open_socket(0, 0);
+ hci_socket = 1;
+
+ bth_init(); /* bluetooth initialization */
+
+ /*inicializace komunikacnich datovych I/O bufferu */
+ bth_inface_setup(0);
+
+ /*TPU channel 1 - inicialize (kontrola paketu + pocatecni zpozdeni)*/
+ bth_init_pkt_controll();
+
+ /*nastaveni zarizeni Bth do slave role*/
+ bth_parametr_slave();
+
+ /*kratka cas. pouza pro bth zarizeni - mazani zasilanych dat*/
+ sleep(1);
+// bth_start_TPU_counter();
+ bth_start();
+
+ /*nekonecna smycka obsluhujici bth, pc ...*/
+ do {
+ int ret;
+ ret = read(hci_socket, &zn_bth, sizeof(zn_bth));
+ if(ret > 0)
+ {
+ bth_recieve_packet(zn_bth);
+ };
+
+ l2cap_send_data(0, 0);
+ bth_send_queue(); /* send built packets if there are any */
+ } while(1);
+ return 0;
+};
--- /dev/null
+CONFIG_BLUETOOTH_LINUX=y
+LN_HEADERS=y
+
+DEFS+=-g -O0 -DBTH_LX
\ No newline at end of file
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+# -*- makefile -*-
+
+include_HEADERS = types.h
--- /dev/null
+#define __KERNEL__
+#include <linux/types.h>
+#include <inttypes.h>
+
--- /dev/null
+;; -*- emacs-lisp -*-
+;;
+;; This file is processed by the dirvars emacs package. Each variable
+;; setting below is performed when this dirvars file is loaded.
+;;
+c-basic-offset: 2
+indent-tabs-mode: nil
+tab-width: 2
+;show-trailing-whitespace: t
+;indicate-empty-lines: t
+
# -*- makefile -*-
-bin_PROGRAMS = Main
+bin_PROGRAMS = mirosot
-Main_SOURCES = mirosot_main.c cmd_pxmc.c
+mirosot_SOURCES = mirosot_main.c cmd_pxmc.c cmd_bth.c
-Main_LIBS = boot_fn arch_drivers excptvec misc pxmc m sci_channels bluetooth
-Main_MOREOBJS = $(USER_LIB_DIR)/system_stub.o
+mirosot_LIBS = boot_fn arch_drivers excptvec misc pxmc m sci_channels mirobt
+mirosot_MOREOBJS = $(USER_LIB_DIR)/system_stub.o
--- /dev/null
+#include <cmd_proc.h>
+#include <cmd_bth.h>
+#include <string.h>
+
+cmd_io_t cmd_io_bth;
+
+
+int cmd_bth_processor_run(void)
+{
+ int val;
+ cmd_io_t* cmd_io;
+
+ cmd_io=&cmd_io_bth;
+ if(cmd_bth_line_out(cmd_io))
+ return 1;
+
+ if(cmd_bth_line_in(cmd_io)<=0)
+ return 0;
+
+ if(cmd_bth){
+ val=proc_cmd_line(cmd_io, cmd_bth, cmd_io->priv.ed_line.in->buf);
+ }else{
+ val=-CMDERR_BADCMD;
+ }
+
+ if(cmd_io->priv.ed_line.out->inbuf){
+ cmd_io_putc(cmd_io,'\r');
+ cmd_io_putc(cmd_io,'\n');
+
+ }else if(val<0){
+ char s[20];
+ cmd_io_write(&cmd_io_bth,"ERROR ",6);
+ i2str(s,-val,0,0);
+ cmd_io_write(cmd_io,s,strlen(s));
+ cmd_io_putc(cmd_io,'\r');
+ cmd_io_putc(cmd_io,'\n');
+ }
+ return 1;
+}
+
+
+++ /dev/null
-#ifndef CMD_BTH_H
-#define CMD_BTH_H
-
-/* Bluetooth specific */
-
-cmd_des_t const **cmd_bth;
-
-cmd_io_t cmd_io_bth;
-
-int cmd_bth_line_out(cmd_io_t *cmd_io);
-
-int cmd_bth_line_in(cmd_io_t *cmd_io);
-
-char *cmd_bth_rdline(cmd_io_t *cmd_io, int mode);
-
-#endif
#include <cpu_def.h>
#include <pxmc.h>
#include "cmd_pxmc.h"
-
+#include <utils.h>
/**
* cmd_opchar_getreg - selects the right axis
int val;
pxmc_state_t *mcs;
if(*param[2]!=':') return -CMDERR_OPCHAR;
-// if((mcs=cmd_opchar_getreg(cmd_io,des,param))==NULL) return -CMDERR_BADREG;
+ if((mcs=cmd_opchar_getreg(cmd_io,des,param))==NULL) return -CMDERR_BADREG;
if(mcs->pxms_flg&PXMS_BSY_m) return -CMDERR_BSYREG;
val=atol(param[3]);
val=pxmc_axis_mode(mcs,val);
*
* Author: Petr Kovacik <kovacp1@feld.cvut.cz>, (C) 2006
*
-* Copyright:
+* Copyright:
*
*/
#define _USE_EXR_LEVELS 1
#include "cmd_pxmc.h"
#include <bth_h8s2638.h>
+/* SCI channel where Bluetooth is connected */
+#define SCI_CHAN_BTH 2
/*struktury prikazu cmd*/
cmd_des_t const cmd_des_help={0, 0,"HELP","prints help for commands",
cmd_do_help,{(char*)&cmd_bth}};
-
+
cmd_des_t const *cmd_rs232_default[]={
&cmd_des_help,
pxms_rp:155l*256,
pxms_rs:0, //pxms_subdiv:8,
pxms_md:8000l<<8, pxms_ms:5000, pxms_ma:10,
- pxms_inp_info:(long)TPU_TCNT1,//TPU_TCNT1 /*chanel TPU A,B*/
+ pxms_inp_info:(long)TPU_TCNT1, //TPU_TCNT1 /*chanel TPU A,B*/
pxms_out_info:(long)PWM_PWBFR1A, /*chanel PWM A,B*/
pxms_ene:0, pxms_erc:0,
pxms_p:40, pxms_i:0, pxms_d:1, pxms_s1:0, pxms_s2:0,
pxmc_state_t *pxmc_main_arr[] = {&mcsX0,&mcsX1};
-#define SUMMOTORS (sizeof(pxmc_main_arr)/sizeof(pxmc_main_arr[0]))
-
pxmc_state_list_t pxmc_main_list = {
pxml_arr:pxmc_main_arr,
- pxml_cnt:SUMMOTORS
+ pxml_cnt:sizeof(pxmc_main_arr)/sizeof(pxmc_main_arr[0])
};
//*******************************************************
void unhandled_exception(void) __attribute__ ((interrupt_handler));
-/**
- * init - shaddow registers, outputs..
- *
- * Initializes P1 and P3 shaddow registers,
- * sets PJ.1, PJ.2, PJ.3 LED as outputs,
- * initialises interrupt vector.
- */
-void init()
-{
- /* initialises interrupt vector */
- excptvec_initfill(unhandled_exception, 0);
-}
/*Interrupt routines*/
void unhandled_exception(void)
{
int val;
cmd_io_t* cmd_io;
-
+
cmd_io=&cmd_io_rs232;
if(cmd_rs232_line_out(cmd_io))
return 1;
-
+
if(cmd_rs232_line_in(cmd_io)<=0)
return 0;
val=-CMDERR_BADCMD;
}
- if(cmd_io->priv.ed_line.out->inbuf){
- cmd_io_putc(cmd_io,'\r');
- cmd_io_putc(cmd_io,'\n');
-
- }else if(val<0){
- char s[20];
- cmd_io_write(&cmd_io_rs232,"ERROR ",6);
- i2str(s,-val,0,0);
- cmd_io_write(cmd_io,s,strlen(s));
- cmd_io_putc(cmd_io,'\r');
- cmd_io_putc(cmd_io,'\n');
- }
- return 1;
-}
-
-
-int cmd_bth_processor_run(void)
-{
- int val;
- cmd_io_t* cmd_io;
-
- cmd_io=&cmd_io_bth;
- if(cmd_bth_line_out(cmd_io))
- return 1;
-
- if(cmd_bth_line_in(cmd_io)<=0)
- return 0;
-
- if(cmd_bth){
- val=proc_cmd_line(cmd_io, cmd_bth, cmd_io->priv.ed_line.in->buf);
- }else{
- val=-CMDERR_BADCMD;
- }
-
if(cmd_io->priv.ed_line.out->inbuf){
cmd_io_putc(cmd_io,'\r');
cmd_io_putc(cmd_io,'\n');
}else if(val<0){
char s[20];
- cmd_io_write(&cmd_io_bth,"ERROR ",6);
+ cmd_io_write(&cmd_io_rs232,"ERROR ",6);
i2str(s,-val,0,0);
cmd_io_write(cmd_io,s,strlen(s));
cmd_io_putc(cmd_io,'\r');
*DIO_PJDDR=0xff; /*output gate*/
*DIO_PEDDR=0xff; /*output gate*/
*DIO_PEDR=0x60; /*0x0-LED - light all; 0x6 -ENA,ENB=1, LE33CD=0*/
- *DIO_PJDR=0x00; //rozsviceni vsech diod na */
-
+ *DIO_PJDR=0x00; //switch on all the LEDs - TODO: Use generic macros fot this
+
/*priority preruseni - SCI > TPU*/
*SYS_SYSCR|=SYSCR_INTM1m;
- *INT_IPRA=0x22; *INT_IPRB=0x22; *INT_IPRC=0x04;
+ *INT_IPRA=0x22; *INT_IPRB=0x22; *INT_IPRC=0x04;
*INT_IPRD=0x40; *INT_IPRE=0x44; *INT_IPRF=0x55;
*INT_IPRG=0x55; *INT_IPRH=0x55; *INT_IPRJ=0x06;
*INT_IPRK=0x67; *INT_IPRM=0x66;
- /*povoleni vsech preruseni atd...*/
+ /* disable and initialize interrupts...*/
cli();
- init();
+ excptvec_initfill(unhandled_exception, 0);
/*nastaveni seriovych linek - Bth, PC*/
- sci_rs232_setmode(RS232_BAUD_RAW | 3, 0, 0, 2); // HCI - hardcoded 115200
+ sci_rs232_setmode(RS232_BAUD_RAW | 3, 0, 0, SCI_CHAN_BTH); // HCI - hardcoded 115200
//sci_rs232_setmode(115200, 0, 0, 2); // HCI
sci_rs232_setmode(19200, 0, 0, sci_rs232_chan_default); //PC
- sti();
+ sti(); /* enable interrupts */
- /*inicializace bluetooth*/
- bth_init();
+ bth_init(); /* bluetooth initialization */
/*inicializace komunikacnich datovych I/O bufferu */
bth_inface_setup(0);
- /*TPU kanal 1 - inicialize (kontrola paketu + pocatecni zpozdeni)*/
+ /*TPU channel 1 - inicialize (kontrola paketu + pocatecni zpozdeni)*/
bth_init_pkt_controll();
/*nastaveni zarizeni Bth do slave role*/
/*kratka cas. pouza pro bth zarizeni - mazani zasilanych dat*/
// bth_start_TPU_counter();
- do
- {
- zn_bth=sci_rs232_recch(2);
- }while(bth_get_timer()<11);
+ do {
+ zn_bth=sci_rs232_recch(SCI_CHAN_BTH);
+ } while(bth_get_timer()<11);
+
bth_start();
- /*nastaveni HW (TPU, PWM)*/
- pxmc_set_pwm_tpu(SUMMOTORS);
+ /* HW setup (TPU, PWM)*/
+ pxmc_set_pwm_tpu();
/*nastaveni DC motoru*/
pxmc_add_pservice_and_mode(4); /*Macro - mod=4 tj. all motors are DC*/
/*nekonecna smycka obsluhujici bth, pc ...*/
- do{
- zn_bth=sci_rs232_recch(2);
+ do {
+ zn_bth=sci_rs232_recch(SCI_CHAN_BTH);
if(zn_bth!=-1)
{
bth_recieve_packet(zn_bth);
};
l2cap_send_data(0, 0);
- bth_send_queue(); /*odesli sestavene pakety, pokod jsou*/
- cmd_bth_processor_run(); /*sber + odesilani cmd prikazu bth*/
- cmd_rs232_processor_run(); /*sber + odesilani cmd prikazu PC*/
-
- }while(1);
+ bth_send_queue(); /* send built packets if there are any */
+ cmd_bth_processor_run(); /* run command processor on bluetooth */
+ cmd_rs232_processor_run(); /* run command processor on serial line */
+ } while(1);
return 0;
};