tux-droid-svn Mailing List for Tux Droid CE (Page 232)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-08 19:42:13
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 226 Modified: api/python/trunk/tuxapi_class.py Log: neimad 2007-04-08 21:41:43 +0200 (Sun, 08 Apr 2007) 209 * Make time_events_Thread() call time.localtime() only once when checking for event deadline. Still calls time.localtime() once per event in events_list. Maybe it should be called once for all events ? svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-04-08 16:56:45 UTC (rev 225) +++ api/python/trunk/tuxapi_class.py 2007-04-08 19:41:43 UTC (rev 226) @@ -502,20 +502,22 @@ ## SYSTEM function #-------------------------------------------------------------------------- def time_events_Thread(self): + def event_due(event): + now = time.localtime() + return event[2] in [now[0], 9999] \ + and event[3] in [now[1], 99] \ + and event[4] in [now[2], 99] \ + and event[5] in [now[3], 99] \ + and event[6] in [now[4], 99] \ + and event[7] in [now[5], 99] while True: if self.parent.connected: for event in self.events_list: - if event[0]!=0: - if event[2]==9999 or event[2]==time.localtime()[0]: - if event[3]==99 or event[3]==time.localtime()[1]: - if event[4]==99 or event[4]==time.localtime()[2]: - if event[5]==99 or event[5]==time.localtime()[3]: - if event[6]==99 or event[6]==time.localtime()[4]: - if event[7]==99 or event[7]==time.localtime()[5]: - if event[0]==CT_SHELL: - self.shell_free(event[1]) - elif event[0]==CT_FUNCTION: - event[1]() + if event[0] != 0 and event_due(event): + if event[0] == CT_SHELL: + self.shell_free(event[1]) + elif event[0] == CT_FUNCTION: + event[1]() time.sleep(1) #============================================================================== |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-08 16:56:50
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 225 Modified: api/python/trunk/tuxapi_class.py Log: neimad 2007-04-08 18:56:45 +0200 (Sun, 08 Apr 2007) 59 * Replaced [None,None,...,None] (64 times) with [None]*64. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-04-08 16:54:40 UTC (rev 224) +++ api/python/trunk/tuxapi_class.py 2007-04-08 16:56:45 UTC (rev 225) @@ -543,13 +543,7 @@ self.on_head_bt_released=None self.on_lwing_bt_released=None self.on_rwing_bt_released=None - self.on_remote_bt=[None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None,None,None,None,None,None,None,\ - None,None,None,None] + self.on_remote_bt=[None]*64 self.on_status=None self.on_remote=None self.on_light_level=None |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-08 16:55:11
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 224 Modified: api/python/trunk/tuxapi_class.py Log: neimad 2007-04-08 18:54:40 +0200 (Sun, 08 Apr 2007) 40 * Removed loads of trailing whitespace. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-04-03 20:15:14 UTC (rev 223) +++ api/python/trunk/tuxapi_class.py 2007-04-08 16:54:40 UTC (rev 224) @@ -167,7 +167,7 @@ value_8b=2 value_16b=3 value_np=4 - + value_type=value_onoff line="" status=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] @@ -259,7 +259,7 @@ if value_type==value_16b: line=line+"%d"%((status[5]*256)+status[6]) return line - + #-------------------------------------------------------------------------- ## Pooling on data arrival from tcp server ## SYSTEM function @@ -355,17 +355,17 @@ self.event.on_remote_bt[ord(self.last_datas_for_event[5])]() if self.event.on_remote!=None: self.event.on_remote(ord(self.last_datas_for_event[5])) - #Mouth open + #Mouth open if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_OPEN_POSITION: if ord(self.last_datas_for_event[5])==1: if self.event.on_mouth_open!=None: self.event.on_mouth_open() - #Mouth close + #Mouth close if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_CLOSED_POSITION: if ord(self.last_datas_for_event[5])==1: if self.event.on_mouth_close!=None: self.event.on_mouth_close() - #Ledl + #Ledl if ord(self.last_datas_for_event[4])==DATAS_STATUS_LEFT_BLUE_LED: if ord(self.last_datas_for_event[5])==1: if self.event.on_left_blue_led_on!=None: @@ -373,7 +373,7 @@ else: if self.event.on_left_blue_led_off!=None: self.event.on_left_blue_led_off() - #Ledr + #Ledr if ord(self.last_datas_for_event[4])==DATAS_STATUS_RIGHT_BLUE_LED: if ord(self.last_datas_for_event[5])==1: if self.event.on_right_blue_led_on!=None: @@ -381,7 +381,7 @@ else: if self.event.on_right_blue_led_off!=None: self.event.on_right_blue_led_off() - #Eyes open/close + #Eyes open/close if ord(self.last_datas_for_event[4])==DATAS_STATUS_EYES_CLOSED_POSITION_SWITCH: if ord(self.last_datas_for_event[5])==1: if self.event.on_eyes_close!=None: @@ -389,7 +389,7 @@ else: if self.event.on_eyes_open!=None: self.event.on_eyes_open() - #Power plug switch + #Power plug switch if ord(self.last_datas_for_event[4])==DATAS_STATUS_POWER_PLUG_SWITCH: if ord(self.last_datas_for_event[5])==1: if self.event.on_power_plugged!=None: @@ -397,7 +397,7 @@ else: if self.event.on_power_unplugged!=None: self.event.on_power_unplugged() - #RF status + #RF status if ord(self.last_datas_for_event[4])==DATAS_STATUS_RF_CONNECTED: if ord(self.last_datas_for_event[5])==1: self.RF_connected=True @@ -407,34 +407,34 @@ self.RF_connected=False if self.event.on_rf_disconnected!=None: self.event.on_rf_disconnected() - #PONG + #PONG if ord(self.last_datas_for_event[4])==DATAS_STATUS_PONG: if self.event.on_pong_received!=None: rcv=ord(self.last_datas_for_event[6]) rem=ord(self.last_datas_for_event[5]) avg=int((100*rcv)/(200-rem)) self.event.on_pong_received(rcv,rem,avg) - #mouth stop + #mouth stop if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_POSITION_COUNTER: if ord(self.last_datas_for_event[5])==0: if self.event.on_mouth_stop!=None: - self.event.on_mouth_stop() - #eyes stop + self.event.on_mouth_stop() + #eyes stop if ord(self.last_datas_for_event[4])==DATAS_STATUS_EYES_POSITION_COUNTER: if ord(self.last_datas_for_event[5])==0: if self.event.on_eyes_stop!=None: - self.event.on_eyes_stop() - - #wings stop + self.event.on_eyes_stop() + + #wings stop if ord(self.last_datas_for_event[4])==DATAS_STATUS_WINGS_POSITION_COUNTER: if ord(self.last_datas_for_event[5])==0: if self.event.on_wings_stop!=None: - self.event.on_wings_stop() - #spin stop + self.event.on_wings_stop() + #spin stop if ord(self.last_datas_for_event[4])==DATAS_STATUS_SPIN_POSITION_COUNTER: if ord(self.last_datas_for_event[5])==0: if self.event.on_spin_stop!=None: - self.event.on_spin_stop() + self.event.on_spin_stop() #============================================================================== # TUXTCPCommunicator - sys - class @@ -1477,8 +1477,8 @@ ## Get version of dongle RF cpu def donglerf_get_version(self): return self.get_firmware_versioning(3) - - ## Get the alsa devices + + ## Get the alsa devices def alsa_devices_enumerate(self): self.TUX_devices=[] self.TUX_devices_count=0 @@ -1519,16 +1519,16 @@ if ((current_tux_device[5]==0x03eb)and(current_tux_device[6]==0xff07)): self.TUX_devices.append(current_tux_device) self.TUX_devices_count=self.TUX_devices_count+1 - - ## Return the number of tux alsa devices + + ## Return the number of tux alsa devices def alsa_devices_count(self): count=0 for ctd in self.TUX_devices: if ctd[2]==0: count=count+1 return count - - ## Get a tux alsa device + + ## Get a tux alsa device def alsa_devices_select(self,number): self.alsa_devices_enumerate() self.alsa_devices_count() @@ -1536,14 +1536,14 @@ i=0 if self.TUX_devices_count>0: for ctd in self.TUX_devices: - if ctd[2]==0: + if ctd[2]==0: if i==number: self.alsa_device="hw:%d,%d"%(ctd[1],ctd[2]) return i=i+1 self.alsa_device="default" else: - self.alsa_device="default" + self.alsa_device="default" #============================================================================== # TUXTCPCommunicator - TTS - class |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-03 20:15:20
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 223 Modified: firmware/tuxdefs/commands.h firmware/tuxup/trunk/main.c Log: jaguarondi 2007-04-03 22:15:14 +0200 (Tue, 03 Apr 2007) 261 - UPD: Added a version_bf_t type equal to the previous version_t with the bitfied, this is more convenient to use inside a single program. - UPD: when an hex file isn't found, exit after the access error instead of reporting that the hex file is not supported. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-04-03 18:28:01 UTC (rev 222) +++ firmware/tuxdefs/commands.h 2007-04-03 20:15:14 UTC (rev 223) @@ -92,9 +92,27 @@ #define INFO_FUXUSB_CMD 0x06 #define VERSION_CMD 0xC8 +/* + * This version_bf_t type can't be used to send the bytes over a channel as the + * order of the bits in the bitfield may be freely rearranged by GCC. + */ typedef struct { uint8_t version_cmd; + uint8_t cpu_nbr :3; /* 3 lower bits are the CPU number */ + uint8_t ver_major :5; /* 5 higher bits are the major version number */ + uint8_t ver_minor; + uint8_t ver_update; +} version_bf_t; + +/* + * This version_t type should be used to send the bytes over a channel such as + * USB or TCP-IP. Use the macros to set or retrieve values of the cpu_ver_maj + * byte. + */ +typedef struct +{ + uint8_t version_cmd; uint8_t cpu_ver_maj; /* 3 lower bits are the CPU number, 5 higher bits are the major version number */ uint8_t ver_minor; uint8_t ver_update; Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-04-03 18:28:01 UTC (rev 222) +++ firmware/tuxup/trunk/main.c 2007-04-03 20:15:14 UTC (rev 223) @@ -171,7 +171,7 @@ * from the hex file and returns 0 if the hex file has a cpu and version * numbers, 1 otherwise. */ -int check_hex_file(char *filename, version_t* version) +int check_hex_file(char *filename, version_bf_t* version) { FILE *fs = NULL; char word[80]; @@ -180,8 +180,8 @@ hex_nr[2]=(char)'\0'; if ((fs = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Unable to open file '%s' for reading", filename); - return 1; + fprintf(stderr, "Unable to open file '%s' for reading\n", filename); + exit(1); } while( fscanf( fs, " %s", word)!=EOF) @@ -205,7 +205,7 @@ int prog_flash(char *filename) { - version_t version; + version_bf_t version; uint8_t cpu_i2c_addr; /* Connect the dongle. */ |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-03 18:28:09
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 222 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/libs/USBDaemon_usb_enum.c firmware/tuxdefs/commands.h Log: jaguarondi 2007-04-03 20:28:01 +0200 (Tue, 03 Apr 2007) 227 - UPD: I didn't changed the daemon according to the last update made in tuxcore and commands.h for the version numbers, so the build was broken. Now the daemon should be OK though I couldn't test it (no tux on hands right now) svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-04-03 18:25:47 UTC (rev 221) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-04-03 18:28:01 UTC (rev 222) @@ -628,7 +628,7 @@ switch(data[0]) { case TUX_REQ_INFO_VERSION: - result[1] = hw_version[data[1]].ver_major; + result[1] = CPU_VER_MAJ(hw_version[data[1]].cpu_ver_maj); result[2] = hw_version[data[1]].ver_minor; result[3] = hw_version[data[1]].ver_update; result[4] = (unsigned char)((hw_revision[data[1]].revision)&0xFF00)>>8; Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-04-03 18:25:47 UTC (rev 221) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-04-03 18:28:01 UTC (rev 222) @@ -142,7 +142,7 @@ tmp = (new_status[3] << 24) + (new_status[2] << 16) + (new_status[1] << 8) + (new_status[0]); hw_ver = (version_t *) &tmp; - last_cpu_ver = hw_ver->cpu_nbr; + last_cpu_ver = CPU_VER_MAJ(hw_ver->cpu_ver_maj); hw_version[last_cpu_ver] = *hw_ver; } Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-04-03 18:25:47 UTC (rev 221) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-04-03 18:28:01 UTC (rev 222) @@ -79,7 +79,7 @@ error = usb_claim_interface(tux_hdl, TUX_INTERFACE); if (error != 0) { - usb_detach_kernel_driver_np(tux_hdl, TUX_INTERFACE); + /*usb_detach_kernel_driver_np(tux_hdl, TUX_INTERFACE);*/ error = usb_claim_interface(tux_hdl, TUX_INTERFACE); if (error != 0) { Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-04-03 18:25:47 UTC (rev 221) +++ firmware/tuxdefs/commands.h 2007-04-03 18:28:01 UTC (rev 222) @@ -95,11 +95,13 @@ typedef struct { uint8_t version_cmd; - uint8_t bitfield; /* 3 lower bits are the CPU number, 5 higher bits are the major version number */ + uint8_t cpu_ver_maj; /* 3 lower bits are the CPU number, 5 higher bits are the major version number */ uint8_t ver_minor; uint8_t ver_update; } version_t; #define CPU_VER_JOIN(cpu_nbr, ver_major) ((cpu_nbr & 0x7) + (ver_major << 3)) +#define CPU_VER_CPU(cpu_ver_maj) (cpu_ver_maj & 0x07) /* cpu_nbr: 3 lower bits */ +#define CPU_VER_MAJ(cpu_ver_maj) ((cpu_ver_maj & 0xF8) >> 3) /* ver_major: 5 higher bits */ #define REVISION_CMD 0xC9 typedef struct |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-03 18:26:21
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 221 Modified: daemon/trunk/Makefile Log: jaguarondi 2007-04-03 20:25:47 +0200 (Tue, 03 Apr 2007) 94 - UPD: followed some suggestions of Kiffin Gish that updated the Makefile to run on FreeBSD6.1 svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: daemon/trunk/Makefile =================================================================== --- daemon/trunk/Makefile 2007-04-03 15:10:05 UTC (rev 220) +++ daemon/trunk/Makefile 2007-04-03 18:25:47 UTC (rev 221) @@ -16,12 +16,12 @@ OBJ_DIR = Debug OUTPUT_DIR = . TARGET = tuxdaemon - C_INCLUDE_DIRS = -I"/usr/include/glib-2.0" -I"/usr/lib/glib-2.0/include" + C_INCLUDE_DIRS = -I"/usr/include/glib-2.0" -I"/usr/lib/glib-2.0/include" -I"/usr/local/include" C_PREPROC = CFLAGS = -pipe -Wall -g2 -O0 -DUSB_DEBUG - LIB_DIRS = -L"/usr/include/glib-2.0" -L"/usr/lib/glib-2.0/include" - LIBS = -lglib-2.0 -lgthread-2.0 -lusb - LDFLAGS = -pipe + LIB_DIRS = -L"/usr/include/glib-2.0" -L"/usr/lib/glib-2.0/include" -L"/usr/local/lib" + LIBS = -lglib-2.0 -lgthread-2.0 -lpthread -lusb + LDFLAGS = -pipe endif ifeq ($(CFG),Release) |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-03 15:10:50
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 220 Modified: daemon/branches/CPPDaemon/TCP.cpp daemon/branches/CPPDaemon/TCP.h Log: srikantap 2007-04-03 17:10:05 +0200 (Tue, 03 Apr 2007) 38 CommManager changes. sending ack test. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: daemon/branches/CPPDaemon/TCP.cpp =================================================================== --- daemon/branches/CPPDaemon/TCP.cpp 2007-04-02 18:23:39 UTC (rev 219) +++ daemon/branches/CPPDaemon/TCP.cpp 2007-04-03 15:10:05 UTC (rev 220) @@ -30,6 +30,10 @@ { ::memcpy(&_msg[4], data, 12); } +void Message::setMessageData(char* data, int size) +{ + ::memcpy(&_msg[4], data, size); +} Message::MESSAGE_DEST Message::getDestination() { @@ -262,13 +266,14 @@ } else { + //TODO: FIXME Message msg (str.c_str()); Message::MESSAGE_DEST dest = msg.getDestination(); if (Message::MESSAGE_DEST_SUB_DAEMON == dest || Message::MESSAGE_DEST_CLIENT == dest) { - handleMessage(msg); + handleMessage(clients[i], msg); } else { @@ -281,7 +286,7 @@ } -void CommManager::handleMessage(Message& msg) +void CommManager::handleMessage(Client& client, Message& msg) { printf("CommManager:: Handling msg\n"); @@ -295,6 +300,30 @@ { printf("CommManager: REQUEST\n"); } + + //TODO: FIXME + char *temp = msg.getMessage(); + Message ack(temp); + sendAck(client, msg); } + +void CommManager::sendAck(Client& client, Message& msg) +{ + /*FIXME: JUST FOR SAKE OF TESTING! + * REMOVE THIS AFTER TESTING + * NEED TO USE MSG CLASS IN BETTER WAY + **/ + msg.setDataType(0x05); + char ackByte = 0x01; + msg.setMessageData(&ackByte, 1); + + //TODO: FIXME + char *temp = msg.getMessage(); + string message(temp); + client.send(message); + printf("********************* Sending to client ****************\n"); + msg.dump(); + printf("********************************************************\n"); +} /***************************************************************/ Modified: daemon/branches/CPPDaemon/TCP.h =================================================================== --- daemon/branches/CPPDaemon/TCP.h 2007-04-02 18:23:39 UTC (rev 219) +++ daemon/branches/CPPDaemon/TCP.h 2007-04-03 15:10:05 UTC (rev 220) @@ -9,6 +9,16 @@ static const int CLIENT_NAME_SIZE = 256; static const int MESSAGE_SIZE = 16; +/** + * Message Class: + * FIXME: THIS CLASS IS A UGLY, UGLY HACK + * FIXME: CLEAN THIS CLASS. + * FIXME: THIS CLASS WILL BE USED ALL THRU THE SYSTEM, SO + * CREATE SOME GENERIC INTERFACES, CLEANUP, DO SOMETHING!! + * FIXME: NEED TO CREATE CLEAN INTERFACES + * FIXME: NEED TO RESOLVE THE RELATIONSHIP B/W THIS CLASS, STRING + * AND CHAR. + **/ class Message { public: @@ -32,6 +42,7 @@ void setDataType(char dataType); void setSubDataType(char subDataType); void setMessageData(char* data); + void setMessageData(char* data, int size); MESSAGE_DEST getDestination(); @@ -77,7 +88,8 @@ bool addClient(Client* newClient); bool processMessages(); bool stayAlive() { return (sockId.is_valid()); }; - void handleMessage(Message& msg); + void handleMessage(Client& client, Message& msg); + void sendAck(Client& client, Message& msg); Client *clients; |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-02 18:24:20
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 219 Added: daemon/branches/CPPDaemon/TuxDeviceManager.cpp daemon/branches/CPPDaemon/TuxDeviceManager.h Modified: daemon/branches/CPPDaemon/Dispatcher.h daemon/branches/CPPDaemon/Makefile daemon/branches/CPPDaemon/TCP.cpp daemon/branches/CPPDaemon/TCP.h daemon/branches/CPPDaemon/UsbHandler.cpp daemon/branches/CPPDaemon/UsbHandler.h Log: srikantap 2007-04-02 20:23:39 +0200 (Mon, 02 Apr 2007) 76 Added TuxDeviceManager class. Handles Tux Device (Usb open/read/write, etc) svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: daemon/branches/CPPDaemon/Dispatcher.h =================================================================== --- daemon/branches/CPPDaemon/Dispatcher.h 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/Dispatcher.h 2007-04-02 18:23:39 UTC (rev 219) @@ -1,6 +1,10 @@ #include "TCP.h" #include "MsgQueue.h" +/** + * Should this class run as a thread? + * Does it need its own msgQ? + */ class Dispatcher { public: Modified: daemon/branches/CPPDaemon/Makefile =================================================================== --- daemon/branches/CPPDaemon/Makefile 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/Makefile 2007-04-02 18:23:39 UTC (rev 219) @@ -1,6 +1,7 @@ default: - g++ main.cpp Socket.cpp TCP.cpp MsgQueue.cpp UsbHandler.cpp Dispatcher.cpp -lpthread + g++ main.cpp Socket.cpp TCP.cpp MsgQueue.cpp \ + UsbHandler.cpp Dispatcher.cpp TuxDeviceManager.cpp -lpthread -lusb clean: rm -f *.out *.o Modified: daemon/branches/CPPDaemon/TCP.cpp =================================================================== --- daemon/branches/CPPDaemon/TCP.cpp 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/TCP.cpp 2007-04-02 18:23:39 UTC (rev 219) @@ -31,17 +31,17 @@ ::memcpy(&_msg[4], data, 12); } -char Message::getDestination() +Message::MESSAGE_DEST Message::getDestination() { - return (_msg[0]); + return ( (Message::MESSAGE_DEST) _msg[0]); } char Message::getSubDestination() { return (_msg[1]); } -char Message::getDataType() +Message::MESSAGE_TYPE Message::getDataType() { - return (_msg[2]); + return ( (MESSAGE_TYPE) _msg[2]); } char Message::getDataSubType() { @@ -229,6 +229,7 @@ { clients[i] = *newClient; clients[i].set_non_blocking(true); + printf("CommManager: Added New Client %d\n", i); return true; } } @@ -257,27 +258,43 @@ else if(recv_ret == 0) { clients[i].invalidate(); + printf("CommManager: Removed client %d\n", i); } else { Message msg (str.c_str()); - //msg.dump(); - // TODO: USB.dispatch(clients[i].msg); - /*int s = usbQueue->send((char *) str.c_str(), MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); - if (s < 0) + Message::MESSAGE_DEST dest = msg.getDestination(); + if (Message::MESSAGE_DEST_SUB_DAEMON == dest + || Message::MESSAGE_DEST_CLIENT == dest) { - perror ("Msg send"); + handleMessage(msg); } - */ - Dispatcher d; - d.dispatch(msg); - printf("TCP: Dispatched...\n"); + else + { + Dispatcher d; + d.dispatch(msg); + } } } } } +void CommManager::handleMessage(Message& msg) +{ + printf("CommManager:: Handling msg\n"); + + Message::MESSAGE_TYPE type = msg.getDataType(); + + if (Message::MESSAGE_COMMAND == type) + { + printf("CommManager:: COMMAND\n"); + } + else if (Message::MESSAGE_REQUEST == type) + { + printf("CommManager: REQUEST\n"); + } +} /***************************************************************/ Modified: daemon/branches/CPPDaemon/TCP.h =================================================================== --- daemon/branches/CPPDaemon/TCP.h 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/TCP.h 2007-04-02 18:23:39 UTC (rev 219) @@ -12,16 +12,31 @@ class Message { public: + typedef enum + { + MESSAGE_COMMAND, + MESSAGE_REQUEST, + } MESSAGE_TYPE; + typedef enum + { + MESSAGE_DEST_MASTER_DAEMON, + MESSAGE_DEST_SUB_DAEMON, + MESSAGE_DEST_TUX, + MESSAGE_DEST_RESOURCE, + MESSAGE_DEST_CLIENT, + } MESSAGE_DEST; + void setSource(char source); void setSubSource(char subSource); void setDataType(char dataType); void setSubDataType(char subDataType); void setMessageData(char* data); - char getDestination(); + MESSAGE_DEST getDestination(); + char getSubDestination(); - char getDataType(); + MESSAGE_TYPE getDataType(); char getDataSubType(); char* getMessageData(); @@ -62,6 +77,8 @@ bool addClient(Client* newClient); bool processMessages(); bool stayAlive() { return (sockId.is_valid()); }; + void handleMessage(Message& msg); + Client *clients; struct sockaddr_in tcp_server_sockaddr; Added: daemon/branches/CPPDaemon/TuxDeviceManager.cpp =================================================================== --- daemon/branches/CPPDaemon/TuxDeviceManager.cpp (rev 0) +++ daemon/branches/CPPDaemon/TuxDeviceManager.cpp 2007-04-02 18:23:39 UTC (rev 219) @@ -0,0 +1,112 @@ +#include <usb.h> +#include <stdio.h> +#include "TuxDeviceManager.h" + + +TuxDeviceManager::TuxDeviceManager* TuxDeviceManager::instance = NULL; + +void TuxDeviceManager::send(const char* msg) +{ + printf("TuxDeviceManager::Send: Writing to tux...\n"); + usb_interrupt_write(deviceHandle, TUX_WRITE_EP, (char *) msg, TUX_SEND_LENGTH, 5000); + +} + +bool TuxDeviceManager::initializeDevice() +{ + bool status; + + if (deviceIsAvailable()) + { + return (initDevice()); + } + else + { + return (false); + } +} + +bool TuxDeviceManager::deviceIsAvailable() +{ + struct usb_bus *bus; + //struct usb_device *device; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + for(bus = usb_busses; bus; bus = bus->next) + { + for (device = bus->devices; device; device = device->next) + { + if ((device->descriptor.idVendor == TUX_VID) + && (device->descriptor.idProduct == TUX_PID)) + { + return true; + } + } + } + + return false; +} + +bool TuxDeviceManager::initDevice() +{ + // usb_dev_handle *deviceHandle; + int error; + + /* Open usb device */ + deviceHandle = usb_open(device); + if (!deviceHandle) + { + // printf("Can't open device: %s (%d)\n", strerror(errno), errno); + printf("Can't open device\n"); + return false; + } + + /* Claim device interface */ + error = usb_claim_interface(deviceHandle, TUX_INTERFACE); + if (error != 0) + { + usb_detach_kernel_driver_np(deviceHandle, TUX_INTERFACE); + error = usb_claim_interface(deviceHandle, TUX_INTERFACE); + if (error != 0) + { + // printf("Can't claim interface: %s (%d)\n", strerror(errno), errno); + printf("Can't open device\n"); + return false; + } + } + /* Set altinterface */ + error = usb_set_altinterface(deviceHandle, 0); + if (error != 0) + { + printf("usb_set_altinterface error: %d : %s \n", error, usb_strerror()); + return false; + } + + return (true); + // return deviceHandle; +} + +TuxDeviceManager& TuxDeviceManager::getInstance() +{ + if (NULL != instance) + { + return (*instance); + } + + instance = new TuxDeviceManager; + return (*instance); +} + +TuxDeviceManager::TuxDeviceManager() : + TUX_PID(0xFF07) , TUX_VID(0x03EB), TUX_INTERFACE(0x03), + TUX_WRITE_EP(0x05), TUX_READ_EP(0x84), TUX_SEND_LENGTH(0x05) +{ +} + +TuxDeviceManager::~TuxDeviceManager() +{ +} + Property changes on: daemon/branches/CPPDaemon/TuxDeviceManager.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: daemon/branches/CPPDaemon/TuxDeviceManager.h =================================================================== --- daemon/branches/CPPDaemon/TuxDeviceManager.h (rev 0) +++ daemon/branches/CPPDaemon/TuxDeviceManager.h 2007-04-02 18:23:39 UTC (rev 219) @@ -0,0 +1,36 @@ +#ifndef __TUX_DEV_MGR_H__ +#define __TUX_DEV_MGR_H__ + +#include <usb.h> + +class TuxDeviceManager +{ + public: + static TuxDeviceManager& getInstance(); + + bool deviceIsAvailable(); + bool initializeDevice(); + bool initDevice(); + void send(const char* msg); + + + ~TuxDeviceManager(); + + + private: + TuxDeviceManager(); + const TuxDeviceManager& operator= (TuxDeviceManager& tux); + + static TuxDeviceManager* instance; + usb_dev_handle* deviceHandle; + struct usb_device *device; + + const int TUX_PID; + const int TUX_VID; + const int TUX_INTERFACE; + const int TUX_WRITE_EP; + const int TUX_READ_EP; + const int TUX_SEND_LENGTH; +}; + +#endif Property changes on: daemon/branches/CPPDaemon/TuxDeviceManager.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Modified: daemon/branches/CPPDaemon/UsbHandler.cpp =================================================================== --- daemon/branches/CPPDaemon/UsbHandler.cpp 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/UsbHandler.cpp 2007-04-02 18:23:39 UTC (rev 219) @@ -4,6 +4,7 @@ #include "UsbHandler.h" #include "MsgQueue.h" +#include "TuxDeviceManager.h" #include "TCP.h" UsbHandler::UsbHandler() @@ -28,10 +29,31 @@ while (1) { usbQ->recv(message, MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); + printf("UsbHandler:: RECEIVED MSG\n"); Message msg(message); - msg.dump(); + handleMessage(msg); } } +void UsbHandler::handleMessage(Message& msg) +{ + // msg.dump(); + + Message::MESSAGE_TYPE type = msg.getDataType(); + + if (Message::MESSAGE_COMMAND == type) + { + printf("UsbHandler: COMMAND\n"); + TuxDeviceManager& tux = TuxDeviceManager::getInstance(); + const char* cmd = msg.getMessageData(); + tux.send(cmd); + } + else if (Message::MESSAGE_REQUEST == type) + { + printf("UsbHandler: REQUEST\n"); + } + + +} Modified: daemon/branches/CPPDaemon/UsbHandler.h =================================================================== --- daemon/branches/CPPDaemon/UsbHandler.h 2007-03-30 16:03:10 UTC (rev 218) +++ daemon/branches/CPPDaemon/UsbHandler.h 2007-04-02 18:23:39 UTC (rev 219) @@ -1,4 +1,5 @@ #include "MsgQueue.h" +#include "TCP.h" class UsbHandler { @@ -10,5 +11,7 @@ ~UsbHandler(); private: + void handleMessage(Message& msg); + MsgQueue* usbQ; }; |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-30 16:03:19
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 218 Added: firmware/tuxup/tags/0.1.1/ Modified: Log: jaguarondi 2007-03-30 18:03:10 +0200 (Fri, 30 Mar 2007) 30 - TAG: release 0.1.1 of tuxup svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Copied: firmware/tuxup/tags/0.1.1 (from rev 217, firmware/tuxup/trunk) |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-30 16:00:24
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 217 Modified: firmware/tuxup/trunk/CHANGES Log: jaguarondi 2007-03-30 18:00:18 +0200 (Fri, 30 Mar 2007) 16 Updated CHANGES. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: firmware/tuxup/trunk/CHANGES =================================================================== --- firmware/tuxup/trunk/CHANGES 2007-03-30 15:53:30 UTC (rev 216) +++ firmware/tuxup/trunk/CHANGES 2007-03-30 16:00:18 UTC (rev 217) @@ -7,6 +7,12 @@ ---------------------------------------------------------------------- Current: +0.1.1: + + * Added a check whether dfu-programmer is installed. + * Checking if the old firmware is used and tell to replug with the button pressed. + * Displayed messages have been improved and cleaned. + 0.1.0: * BUG: fixed bug #1 Segfault when a hex file contained a line of data that |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-30 15:54:08
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 216 Modified: firmware/tuxup/trunk/version.h Log: jaguarondi 2007-03-30 17:53:30 +0200 (Fri, 30 Mar 2007) 23 Preparing 0.1.1 release svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: firmware/tuxup/trunk/version.h =================================================================== --- firmware/tuxup/trunk/version.h 2007-03-29 16:11:30 UTC (rev 215) +++ firmware/tuxup/trunk/version.h 2007-03-30 15:53:30 UTC (rev 216) @@ -22,6 +22,6 @@ #ifndef version_h #define version_h -#define VERSION "0.1.1 (SVN/UNRELEASED)" +#define VERSION "0.1.1" #endif |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-29 16:11:59
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 215 Added: daemon/branches/CPPDaemon/Dispatcher.cpp daemon/branches/CPPDaemon/Dispatcher.h Modified: daemon/branches/CPPDaemon/Makefile daemon/branches/CPPDaemon/MsgQueue.cpp daemon/branches/CPPDaemon/MsgQueue.h daemon/branches/CPPDaemon/TCP.cpp daemon/branches/CPPDaemon/TCP.h daemon/branches/CPPDaemon/main.cpp Log: srikantap 2007-03-29 18:11:30 +0200 (Thu, 29 Mar 2007) 125 Added dispatcher class. It is supposed to be the central 'router' sort-of process which routes messages all round the system. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Added: daemon/branches/CPPDaemon/Dispatcher.cpp =================================================================== --- daemon/branches/CPPDaemon/Dispatcher.cpp (rev 0) +++ daemon/branches/CPPDaemon/Dispatcher.cpp 2007-03-29 16:11:30 UTC (rev 215) @@ -0,0 +1,64 @@ +#include "Dispatcher.h" +#include "TCP.h" +#include "MsgQueue.h" +#include "Common.h" + + +Dispatcher::Dispatcher() +{ + key_t key; + if ((key = ftok(FTOK_PATH_NAME, 'S')) == -1) + { + perror("ftok"); + } + + usbQ = new MsgQueue(key, 0777); +} + +Dispatcher::~Dispatcher() +{ +} + + +bool Dispatcher::dispatch(Message& msg) +{ + int s = 0; + bool result = false; + + switch (msg.getDestination()) + { + case DESTINATION_TUX: + s = usbQ->send((char *) msg.getMessage(), msg.size(), USB_QUEUE_MSG_TYPE); + if (s < 0) + { + perror ("Msg send"); + } + else + { + printf("DISPATCHER: Successfully sent to usbQ\n"); + } + result = true; + break; + + default: + printf("DISPATCHER: Message of type %d received\n", msg.getDestination()); + break; + } + + return (result); +} + +bool Dispatcher::dispatch(char* message) +{ + + Message msg(message); + + switch (msg.getDestination()) + { + case DESTINATION_TUX: + break; + + default: + break; + } +} Property changes on: daemon/branches/CPPDaemon/Dispatcher.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: daemon/branches/CPPDaemon/Dispatcher.h =================================================================== --- daemon/branches/CPPDaemon/Dispatcher.h (rev 0) +++ daemon/branches/CPPDaemon/Dispatcher.h 2007-03-29 16:11:30 UTC (rev 215) @@ -0,0 +1,27 @@ +#include "TCP.h" +#include "MsgQueue.h" + +class Dispatcher +{ + public: + + enum _Destination + { + DESTINATION_MASTER_DAEMON, + DESTINATION_SUB_DAEMON, + DESTINATION_TUX, + DESTINATION_RESOURCE, + DESTINATION_CLIENT, + DESTINATION_DONGLE + }; + + Dispatcher(); + ~Dispatcher(); + + bool dispatch(char* message); + bool dispatch(Message& msg); + + private: + + MsgQueue* usbQ; +}; Property changes on: daemon/branches/CPPDaemon/Dispatcher.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Modified: daemon/branches/CPPDaemon/Makefile =================================================================== --- daemon/branches/CPPDaemon/Makefile 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/Makefile 2007-03-29 16:11:30 UTC (rev 215) @@ -1,6 +1,6 @@ default: - g++ main.cpp Socket.cpp TCP.cpp MsgQueue.cpp UsbHandler.cpp -lpthread + g++ main.cpp Socket.cpp TCP.cpp MsgQueue.cpp UsbHandler.cpp Dispatcher.cpp -lpthread clean: rm -f *.out *.o Modified: daemon/branches/CPPDaemon/MsgQueue.cpp =================================================================== --- daemon/branches/CPPDaemon/MsgQueue.cpp 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/MsgQueue.cpp 2007-03-29 16:11:30 UTC (rev 215) @@ -14,6 +14,7 @@ } MsgBuf; MsgQueue::MsgQueue(int key) + : msgFlag(0) { if((id = msgget((key_t)key, IPC_CREAT|0777)) == -1) perror("msgget"); @@ -21,6 +22,7 @@ MsgQueue::MsgQueue(int key,int perm) + : msgFlag(0) { if((id = msgget((key_t)key, perm)) == -1) perror("msgget"); @@ -67,7 +69,7 @@ memset(packet.data,0,sizeof(packet.data)); memcpy(packet.data,buf,len); - return msgsnd(id, &packet, len, 0); + return msgsnd(id, &packet, len, msgFlag); } int MsgQueue::recv(char *buf, int len) @@ -75,7 +77,7 @@ int ret; MsgBuf packet; - ret = msgrcv(id, &packet, len,0,0); + ret = msgrcv(id, &packet, len, 0, msgFlag); memcpy(buf,packet.data,len); @@ -91,7 +93,7 @@ packet.type = type; - ret = msgrcv(id, &packet, len,type,0); + ret = msgrcv(id, &packet, len, type, 0); memcpy(buf,packet.data,len); Modified: daemon/branches/CPPDaemon/MsgQueue.h =================================================================== --- daemon/branches/CPPDaemon/MsgQueue.h 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/MsgQueue.h 2007-03-29 16:11:30 UTC (rev 215) @@ -18,6 +18,11 @@ void release(); int getRandomType(); + void setNonBlocking() + { + msgFlag |= IPC_NOWAIT; + }; + int send(string msg); int send(string msg,long type); int send(char *buf, int len); @@ -27,6 +32,7 @@ private: int id; + int msgFlag; }; #endif Modified: daemon/branches/CPPDaemon/TCP.cpp =================================================================== --- daemon/branches/CPPDaemon/TCP.cpp 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/TCP.cpp 2007-03-29 16:11:30 UTC (rev 215) @@ -8,6 +8,7 @@ #include "Common.h" #include "TCP.h" #include "Socket.h" +#include "Dispatcher.h" void Message::setSource(char source) { @@ -263,11 +264,15 @@ //msg.dump(); // TODO: USB.dispatch(clients[i].msg); - int s = usbQueue->send((char *) str.c_str(), MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); + /*int s = usbQueue->send((char *) str.c_str(), MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); if (s < 0) { perror ("Msg send"); } + */ + Dispatcher d; + d.dispatch(msg); + printf("TCP: Dispatched...\n"); } } } Modified: daemon/branches/CPPDaemon/TCP.h =================================================================== --- daemon/branches/CPPDaemon/TCP.h 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/TCP.h 2007-03-29 16:11:30 UTC (rev 215) @@ -1,3 +1,5 @@ +#ifndef __TCP_H__ +#define __TCP_H__ #include "Socket.h" #include "MsgQueue.h" @@ -23,6 +25,8 @@ char getDataSubType(); char* getMessageData(); + char* getMessage() { return &(_msg[0]); }; + void dump(); int size() { return (MESSAGE_SIZE); }; @@ -85,3 +89,4 @@ string _name; }; +#endif Modified: daemon/branches/CPPDaemon/main.cpp =================================================================== --- daemon/branches/CPPDaemon/main.cpp 2007-03-29 13:19:41 UTC (rev 214) +++ daemon/branches/CPPDaemon/main.cpp 2007-03-29 16:11:30 UTC (rev 215) @@ -22,11 +22,11 @@ pthread_t tcpThread; int thread_ret = pthread_create(&tcpThread, NULL, tcp, (void*) "TCP THREAD"); - printf("Created TCP\n"); + // printf("Created TCP\n"); pthread_t usbThread; pthread_create(&usbThread, NULL, usb, (void*) "USB THREAD"); - printf("Created USB\n"); + // printf("Created USB\n"); pthread_join(tcpThread, NULL); pthread_join(usbThread, NULL); |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-29 13:19:57
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 214 Added: daemon/branches/CPPDaemon/Common.h daemon/branches/CPPDaemon/MsgQueue.cpp daemon/branches/CPPDaemon/MsgQueue.h daemon/branches/CPPDaemon/UsbHandler.cpp daemon/branches/CPPDaemon/UsbHandler.h Modified: daemon/branches/CPPDaemon/Makefile daemon/branches/CPPDaemon/TCP.cpp daemon/branches/CPPDaemon/TCP.h daemon/branches/CPPDaemon/main.cpp Log: srikantap 2007-03-29 15:19:41 +0200 (Thu, 29 Mar 2007) 33 Basic USB Communication framework svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Added: daemon/branches/CPPDaemon/Common.h =================================================================== --- daemon/branches/CPPDaemon/Common.h (rev 0) +++ daemon/branches/CPPDaemon/Common.h 2007-03-29 13:19:41 UTC (rev 214) @@ -0,0 +1,2 @@ +#define FTOK_PATH_NAME "/tmp/tmp.tmp" +#define USB_QUEUE_MSG_TYPE 10 Property changes on: daemon/branches/CPPDaemon/Common.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Modified: daemon/branches/CPPDaemon/Makefile =================================================================== --- daemon/branches/CPPDaemon/Makefile 2007-03-29 12:18:40 UTC (rev 213) +++ daemon/branches/CPPDaemon/Makefile 2007-03-29 13:19:41 UTC (rev 214) @@ -1,6 +1,6 @@ default: - g++ main.cpp Socket.cpp TCP.cpp -lpthread + g++ main.cpp Socket.cpp TCP.cpp MsgQueue.cpp UsbHandler.cpp -lpthread clean: rm -f *.out *.o Added: daemon/branches/CPPDaemon/MsgQueue.cpp =================================================================== --- daemon/branches/CPPDaemon/MsgQueue.cpp (rev 0) +++ daemon/branches/CPPDaemon/MsgQueue.cpp 2007-03-29 13:19:41 UTC (rev 214) @@ -0,0 +1,99 @@ + +#include "MsgQueue.h" +#include <stdio.h> +#include <sys/types.h> +#include <sys/msg.h> +#include <sys/time.h> +#include <string.h> +#include <unistd.h> + +typedef struct +{ + long type; + char data[1024]; +} MsgBuf; + +MsgQueue::MsgQueue(int key) +{ + if((id = msgget((key_t)key, IPC_CREAT|0777)) == -1) + perror("msgget"); +} + + +MsgQueue::MsgQueue(int key,int perm) +{ + if((id = msgget((key_t)key, perm)) == -1) + perror("msgget"); +} + +MsgQueue::~MsgQueue() +{ +} + +void MsgQueue::release() +{ + msgctl(id,IPC_RMID,NULL); +} + +int MsgQueue::getRandomType() +{ + struct timeval t1; + struct timezone tz; + + gettimeofday(&t1,&tz); + return (t1.tv_usec % 100000) + 1; +} + +int MsgQueue::send(string msg) +{ + return send((char *)msg.c_str(),msg.size()); +} + +int MsgQueue::send(string msg, long type) +{ + return send((char *)msg.c_str(),msg.size(),type); +} + +int MsgQueue::send(char *buf, int len) +{ + return send(buf,len,0); +} + +int MsgQueue::send(char *buf, int len, long type) +{ + MsgBuf packet; + + packet.type = type; + memset(packet.data,0,sizeof(packet.data)); + memcpy(packet.data,buf,len); + + return msgsnd(id, &packet, len, 0); +} + +int MsgQueue::recv(char *buf, int len) +{ + int ret; + MsgBuf packet; + + ret = msgrcv(id, &packet, len,0,0); + + memcpy(buf,packet.data,len); + + return ret; +} + +int MsgQueue::recv(char *buf, int len, long type) +{ + int ret; + MsgBuf packet; + + memset(packet.data,'\0',len); + + packet.type = type; + + ret = msgrcv(id, &packet, len,type,0); + + memcpy(buf,packet.data,len); + + return ret; +} Property changes on: daemon/branches/CPPDaemon/MsgQueue.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: daemon/branches/CPPDaemon/MsgQueue.h =================================================================== --- daemon/branches/CPPDaemon/MsgQueue.h (rev 0) +++ daemon/branches/CPPDaemon/MsgQueue.h 2007-03-29 13:19:41 UTC (rev 214) @@ -0,0 +1,32 @@ +#ifndef MSGQUEUE_H +#define MSGQUEUE_H + + +#include <sys/types.h> +#include <sys/ipc.h> +#include <string> + +using namespace std; + +class MsgQueue +{ + public: + + MsgQueue(int key); + MsgQueue(int key ,int perm); + ~MsgQueue(); + void release(); + int getRandomType(); + + int send(string msg); + int send(string msg,long type); + int send(char *buf, int len); + int send(char *buf, int len, long type); + int recv(char *buf, int len); + int recv(char *buf, int len, long type); + + private: + int id; +}; + +#endif Property changes on: daemon/branches/CPPDaemon/MsgQueue.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Modified: daemon/branches/CPPDaemon/TCP.cpp =================================================================== --- daemon/branches/CPPDaemon/TCP.cpp 2007-03-29 12:18:40 UTC (rev 213) +++ daemon/branches/CPPDaemon/TCP.cpp 2007-03-29 13:19:41 UTC (rev 214) @@ -5,6 +5,7 @@ #include <strings.h> #include <pthread.h> +#include "Common.h" #include "TCP.h" #include "Socket.h" @@ -175,6 +176,16 @@ CommManager::CommManager() : clients (new Client[10]) { + key_t key; + + if ((key = ftok(FTOK_PATH_NAME, 'S')) == -1) + { + perror("ftok"); + } + + usbQueue = new MsgQueue(key); + + } void* CommManager::run() @@ -233,9 +244,11 @@ **/ for (int i = 0; i < 10; i++) { + // printf("processing %d\n", i); if(clients[i].is_valid()) { string str; + // printf("Listening to %d\n", i); int recv_ret = clients[i].recv(str); if(recv_ret < 0) { @@ -246,25 +259,15 @@ } else { -#if 0 - char buf[MESSAGE_SIZE]; - const char *const_str = str.c_str(); - ::memcpy(buf, const_str, MESSAGE_SIZE); + Message msg (str.c_str()); + //msg.dump(); - printf("\n********** MSG from %d *********\n", i); - char buf[16]; - for (int i = 0; i < MESSAGE_SIZE; i++) + // TODO: USB.dispatch(clients[i].msg); + int s = usbQueue->send((char *) str.c_str(), MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); + if (s < 0) { - buf[i] = str[i]; - //printf("%d ", str[i]); - printf("%d ", buf[i]); + perror ("Msg send"); } - printf("\n*******************\n"); -#endif - - Message msg (str.c_str()); - msg.dump(); - // TODO: USB.dispatch(clients[i].msg); } } } Modified: daemon/branches/CPPDaemon/TCP.h =================================================================== --- daemon/branches/CPPDaemon/TCP.h 2007-03-29 12:18:40 UTC (rev 213) +++ daemon/branches/CPPDaemon/TCP.h 2007-03-29 13:19:41 UTC (rev 214) @@ -1,5 +1,6 @@ #include "Socket.h" +#include "MsgQueue.h" #include <sys/socket.h> #include <sys/types.h> @@ -61,6 +62,7 @@ Client *clients; struct sockaddr_in tcp_server_sockaddr; Socket sockId; + MsgQueue *usbQueue; }; class CommManager::Client : public Socket Added: daemon/branches/CPPDaemon/UsbHandler.cpp =================================================================== --- daemon/branches/CPPDaemon/UsbHandler.cpp (rev 0) +++ daemon/branches/CPPDaemon/UsbHandler.cpp 2007-03-29 13:19:41 UTC (rev 214) @@ -0,0 +1,37 @@ + +#include "Common.h" + +#include "UsbHandler.h" +#include "MsgQueue.h" + +#include "TCP.h" + +UsbHandler::UsbHandler() +{ + key_t key; + if ((key = ftok(FTOK_PATH_NAME, 'S')) == -1) + { + perror("ftok"); + } + + usbQ = new MsgQueue(key, 0777); +} + +void UsbHandler::displayMsg() +{ +} + +void* UsbHandler::run() +{ + char message[MESSAGE_SIZE]; + + while (1) + { + usbQ->recv(message, MESSAGE_SIZE, USB_QUEUE_MSG_TYPE); + + Message msg(message); + msg.dump(); + } + +} + Property changes on: daemon/branches/CPPDaemon/UsbHandler.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: daemon/branches/CPPDaemon/UsbHandler.h =================================================================== --- daemon/branches/CPPDaemon/UsbHandler.h (rev 0) +++ daemon/branches/CPPDaemon/UsbHandler.h 2007-03-29 13:19:41 UTC (rev 214) @@ -0,0 +1,14 @@ +#include "MsgQueue.h" + +class UsbHandler +{ + public: + void displayMsg(); + void* run(); + + UsbHandler(); + ~UsbHandler(); + + private: + MsgQueue* usbQ; +}; Property changes on: daemon/branches/CPPDaemon/UsbHandler.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Modified: daemon/branches/CPPDaemon/main.cpp =================================================================== --- daemon/branches/CPPDaemon/main.cpp 2007-03-29 12:18:40 UTC (rev 213) +++ daemon/branches/CPPDaemon/main.cpp 2007-03-29 13:19:41 UTC (rev 214) @@ -8,31 +8,42 @@ #include "TCP.h" #include "Socket.h" +#include "UsbHandler.h" -void* temp(void *); +void* tcp(void *); +void* usb(void *); /***************************************************************/ main() { - CommManager *comm = new CommManager(); - Message msg = Message(); + cout << "\n"; - cout << "\n\n"; + pthread_t tcpThread; + int thread_ret = pthread_create(&tcpThread, NULL, tcp, (void*) "TCP THREAD"); + printf("Created TCP\n"); - pthread_t tcpThread; - int thread_ret = pthread_create(&tcpThread, NULL, temp, (void*) "TCP THREAD"); + pthread_t usbThread; + pthread_create(&usbThread, NULL, usb, (void*) "USB THREAD"); + printf("Created USB\n"); + pthread_join(tcpThread, NULL); - printf("Thread ret: %d\n", thread_ret); + pthread_join(usbThread, NULL); + // printf("Thread ret: %d\n", thread_ret); cout << "\n\n"; } -void* temp(void *) +void* tcp(void *) { CommManager *comm = new CommManager; comm->run(); } +void* usb(void *) +{ + UsbHandler *usb = new UsbHandler; + usb->run(); +} |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-29 12:19:10
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 213 Modified: api/python/trunk/tuxapi_class.py Log: jaguarondi 2007-03-29 14:18:40 +0200 (Thu, 29 Mar 2007) 109 - BUG: fixed api issue #4 (tux.cmd.led[lr]_during don't work) where calls to led[lr] had too much arguments. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-03-29 10:03:03 UTC (rev 212) +++ api/python/trunk/tuxapi_class.py 2007-03-29 12:18:40 UTC (rev 213) @@ -1025,7 +1025,7 @@ ## Send command to tux for left led on during a time ## @param seconds : number of seconds def ledl_during(self,seconds): - self.ledl_on(255) + self.ledl_on() time.sleep(seconds) self.ledl_off() @@ -1045,7 +1045,7 @@ ## Send command to tux for right led on during a time ## @param seconds : number of seconds def ledr_during(self,seconds): - self.ledr_on(255) + self.ledr_on() time.sleep(seconds) self.ledr_off() |
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-03-29 10:03:39
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 212 Added: firmware/tuxaudio/trunk/tuxaudio.ld firmware/tuxcore/trunk/tuxcore.ld Modified: firmware/tuxaudio/trunk/Makefile firmware/tuxaudio/trunk/main.c firmware/tuxcore/trunk/Makefile firmware/tuxcore/trunk/global.c firmware/tuxdefs/commands.h Log: jaguarondi 2007-03-29 12:03:03 +0200 (Thu, 29 Mar 2007) 397 - UPD: fixed firmware issue #1 with the patches given by Philippe Teuwen, this now fixes the location of the version, revision and author structures with a linker script in the .version section otherwise gcc is free to change the order. This also fixes the position of the cpu_nbr and ver_major bits in the byte as again gcc is free to change that order though this is much less likely to happen. svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Modified: firmware/tuxaudio/trunk/Makefile =================================================================== --- firmware/tuxaudio/trunk/Makefile 2007-03-27 11:04:28 UTC (rev 211) +++ firmware/tuxaudio/trunk/Makefile 2007-03-29 10:03:03 UTC (rev 212) @@ -54,7 +54,7 @@ ## Linker flags LDFLAGS = $(COMMON) -LDFLAGS += -Wl,--section-start=.version=0x1DF0 -Wl,-Map=tuxaudio.map +LDFLAGS += -Wl,--section-start=.version=0x1DF0 -Wl,-Map=tuxaudio.map tuxaudio.ld ## Linker flags for bootloader BL_LDFLAGS = $(COMMON) Modified: firmware/tuxaudio/trunk/main.c =================================================================== --- firmware/tuxaudio/trunk/main.c 2007-03-27 11:04:28 UTC (rev 211) +++ firmware/tuxaudio/trunk/main.c 2007-03-29 10:03:03 UTC (rev 212) @@ -39,10 +39,10 @@ */ #define CPU_NUMBER TUXAUDIO_CPU_NUM /* audio CPU */ -const author_t author __attribute__((section(".version"))) = {AUTHOR_CMD, AUTHOR_ID, 0}; -const revision_t svn_revision __attribute__((section(".version"))) = {REVISION_CMD, SVN_REV, SVN_STATUS}; -const version_t tag_version __attribute__((section(".version"))) = {VERSION_CMD, CPU_NUMBER, VER_MAJOR, VER_MINOR, VER_UPDATE}; -uint8_t info_flg = 0; /* indocates if version information should be sent */ +const author_t author __attribute__((section("version.3"))) = {AUTHOR_CMD, AUTHOR_ID, 0}; +const revision_t svn_revision __attribute__((section("version.2"))) = {REVISION_CMD, SVN_REV, SVN_STATUS}; +const version_t tag_version __attribute__((section("version.1"))) = {VERSION_CMD, CPU_VER_JOIN(CPU_NUMBER, VER_MAJOR), VER_MINOR, VER_UPDATE}; +uint8_t info_flg = 0; /* indicates if version information should be sent */ void send_info(void) { Added: firmware/tuxaudio/trunk/tuxaudio.ld =================================================================== --- firmware/tuxaudio/trunk/tuxaudio.ld (rev 0) +++ firmware/tuxaudio/trunk/tuxaudio.ld 2007-03-29 10:03:03 UTC (rev 212) @@ -0,0 +1,11 @@ +SECTIONS { + __start_.version = .; + .version : + { + *(version.1) + *(version.2) + *(version.3) + } + __stop_.version = .; +} + Modified: firmware/tuxcore/trunk/Makefile =================================================================== --- firmware/tuxcore/trunk/Makefile 2007-03-27 11:04:28 UTC (rev 211) +++ firmware/tuxcore/trunk/Makefile 2007-03-29 10:03:03 UTC (rev 212) @@ -51,11 +51,11 @@ ## Linker flags LDFLAGS = $(COMMON) -LDFLAGS += -Wl,--section-start=.version=0x1DF0 -Wl,-Map=tuxcore.map +LDFLAGS += -Wl,--section-start=.version=0x1DF0 -Wl,-Map=tuxcore.map tuxcore.ld ## Linker flags for bootloader BL_LDFLAGS = $(COMMON) -BL_LDFLAGS += -Wl,--section-start=.text=0x1E00 -Wl,-Map=tuxcore_bl.map +BL_LDFLAGS += -Wl,--section-start=.text=0x1E00 -Wl,-Map=tuxcore_bl.map ## Intel Hex file production flags HEX_FLASH_FLAGS = -R .eeprom Modified: firmware/tuxcore/trunk/global.c =================================================================== --- firmware/tuxcore/trunk/global.c 2007-03-27 11:04:28 UTC (rev 211) +++ firmware/tuxcore/trunk/global.c 2007-03-29 10:03:03 UTC (rev 212) @@ -50,6 +50,6 @@ */ #define CPU_NUMBER TUXCORE_CPU_NUM /* tuxcore CPU */ -const author_t author __attribute__((section(".version"))) = {AUTHOR_CMD, AUTHOR_ID, 0}; -const revision_t svn_revision __attribute__((section(".version"))) = {REVISION_CMD, SVN_REV, SVN_STATUS}; -const version_t tag_version __attribute__((section(".version"))) = {VERSION_CMD, CPU_NUMBER, VER_MAJOR, VER_MINOR, VER_UPDATE}; +const author_t author __attribute__((section("version.3"))) = {AUTHOR_CMD, AUTHOR_ID, 0}; +const revision_t svn_revision __attribute__((section("version.2"))) = {REVISION_CMD, SVN_REV, SVN_STATUS}; +const version_t tag_version __attribute__((section("version.1"))) = {VERSION_CMD, CPU_VER_JOIN(CPU_NUMBER, VER_MAJOR), VER_MINOR, VER_UPDATE}; Added: firmware/tuxcore/trunk/tuxcore.ld =================================================================== --- firmware/tuxcore/trunk/tuxcore.ld (rev 0) +++ firmware/tuxcore/trunk/tuxcore.ld 2007-03-29 10:03:03 UTC (rev 212) @@ -0,0 +1,11 @@ +SECTIONS { + __start_.version = .; + .version : + { + *(version.1) + *(version.2) + *(version.3) + } + __stop_.version = .; +} + Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-03-27 11:04:28 UTC (rev 211) +++ firmware/tuxdefs/commands.h 2007-03-29 10:03:03 UTC (rev 212) @@ -95,11 +95,11 @@ typedef struct { uint8_t version_cmd; - uint8_t cpu_nbr :3; /* 3 lower bits are the CPU number */ - uint8_t ver_major :5; /* 5 higher bits are the major version number */ + uint8_t bitfield; /* 3 lower bits are the CPU number, 5 higher bits are the major version number */ uint8_t ver_minor; uint8_t ver_update; } version_t; +#define CPU_VER_JOIN(cpu_nbr, ver_major) ((cpu_nbr & 0x7) + (ver_major << 3)) #define REVISION_CMD 0xC9 typedef struct @@ -163,12 +163,12 @@ * LED commands */ -#define LED_ON_CMD 0x1A /* Turn left LED on */ -#define LED_OFF_CMD 0x1B /* Turn left LED off */ -#define LED_L_ON_CMD 0x1C /* Turn left LED on */ -#define LED_L_OFF_CMD 0x1D /* Turn left LED off */ -#define LED_R_ON_CMD 0x1E /* Turn right LED on */ -#define LED_R_OFF_CMD 0x1F /* Turn right LED off */ +#define LED_ON_CMD 0x1A /* Turn all leds on */ +#define LED_OFF_CMD 0x1B /* Turn all leds off */ +#define LED_L_ON_CMD 0x1C /* Turn left led on */ +#define LED_L_OFF_CMD 0x1D /* Turn left led off */ +#define LED_R_ON_CMD 0x1E /* Turn right led on */ +#define LED_R_OFF_CMD 0x1F /* Turn right led off */ #define LED_BLINK_CMD 0x9A /* Blink both leds multiple time */ /* 1st parameter: number of led toggles */ /* 2nd parameter: delay between each led toggle, in multiple of 4ms */ |
From: jaguarondi <c2m...@c2...> - 2007-03-28 08:06:58
|
Author: jaguarondi Date: 2007-03-27 13:04:28 +0200 (mar, 27 mar 2007) New Revision: 211 Modified: firmware/tuxup/trunk/main.c firmware/tuxup/trunk/version.h Log: - ADD: check if dfu-programmer is installed - ADD: check if the old firmware is used and tell to replug with the button pressed - UPD: messages have been improved and cleaned - UPD: moved to version 0.1.1 unreleased Modififirmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-03-26 06:08:50 UTC (rev 210) +++ firmware/tuxup/trunk/main.c 2007-03-27 11:04:28 UTC (rev 211) @@ -31,11 +31,30 @@ #include "version.h" #include "common/commands.h" +/* Messages. */ +const char * msg_old_firmware = \ +"\nERROR: Your dongle firmware is too old to support switching to bootloader"\ +"\nmode automatically.\n"\ +"\n To enter bootloading mode manually, you need to unplug the dongle, press"\ +"\n with a small pin on the button located inside the hole on the belly and,"\ +"\n while keeping it pressed, plug the dongle."\ +"\n The eyes should not turn blue at this time, otherwise try again."\ +"\n Now, reprogram the dongle alone with the command:"\ +"\n 'tuxup /opt/tuxdroid/hex/fusxusb.hex'"\ +"\n (You may use another path depending on the hex files"\ +" you want to use).\n"\ +"\nCheck http://www.tuxisalive.com/documentation/how-to/updating-the-firmware"\ +"\nfor more details.\n"; + +const char* msg_dfu_programmer_not_installed = \ +"\nERROR: dfu-programmer is not installed or is not in your path, tuxup uses"\ +"\nit to reprogram the USB cpu so installing dfu-programmer is mandatory.\n"; + /* Programming modes. */ enum program_modes_t {NONE, ALL, MAIN, INPUTFILES}; /* The name of this program. */ -const char* program_name; +const char* program_name = "tuxup"; /* The version defined in version.h */ const char * program_version = VERSION; @@ -60,6 +79,7 @@ */ void usage (FILE* stream, int exit_code) { + fprintf(stream, "%s %s\n",program_name, program_version ); fprintf(stream, "Usage: %s options [path|file ...]\n", program_name); fprintf (stream, " -m --main Reprogram tuxcore and tuxaudio (flash and eeprom) with hex files located in path.\n" @@ -97,15 +117,24 @@ if (device == NULL) { if (!wait) { - fprintf(stderr, "Tux not found on USB\n"); + fprintf(stderr, "The dongle was not found, now exiting.\n"); exit(1); } } else { - if (verbose) printf("Tux found \n"); + if (verbose) printf("The dongle was found.\n"); + /* Check if we have the old firmware that requires entering + * bootloader mode manually, exits with a message that exlains what + * to do in such a case. */ + if (device->descriptor.bcdDevice < 0x100) + { + fprintf(stderr, msg_old_firmware); + exit(1); + } break; } + sleep(1); wait--; } @@ -187,7 +216,7 @@ printf("[FAIL] Programming of '%s' failed, this file is not a correct hex file for that CPU\n\n", filename); return 1; } - printf("Programming %s in ", filename); + printf("Programming %s in the ", filename); if (version.cpu_nbr == TUXCORE_CPU_NUM) { printf("core CPU\n"); @@ -208,11 +237,6 @@ printf("fux (dongle) RF CPU\n"); cpu_i2c_addr = FUXRF_BL_ADDR; } - else if (version.cpu_nbr == FUXUSB_CPU_NUM) - { - printf("fux (dongle) USB CPU: not implemented yet\n"); - return 1; - } else { printf("Unrecognized CPU number, %s doesn't appear to be compiled for a CPU of tuxdroid.\n", filename); @@ -273,20 +297,34 @@ uint8_t send_data[5] = {0x01, 0x01, 0x00, 0x00, 0xFF}; /* XXX include those as defines in commands.h */ char tmp_string[90]; int ret; - printf("Programming %s in USB CPU\n", filename); + printf("Programming %s in the USB CPU\n", filename); if (pretend) return 0; /* Check if the dongle is already in bootloader mode */ if (verbose) { - fprintf(stdout,"Testing if the dongle is already in bootloader mode. If it is not, 'no device present' will be reported, don't worry about it\n"); + fprintf(stdout,"Testing if the dongle is already in bootloader mode.\n"\ + "If it is not, 'no device present' will be reported.\n"); ret = system("dfu-programmer at89c5130 get bootloader-version"); } else ret = system("dfu-programmer at89c5130 get bootloader-version 2> /dev/null"); + + /* If dfu-programmer didn't detect the dongle, we try to set it in bootloader mode with the specific command */ if (ret) { + /* Check if dfu-programmer is installed */ + if (ret == 32512) /* XXX a better way to code that error, a define? */ + { + fprintf(stdout, msg_dfu_programmer_not_installed); + exit(1); + } + if (verbose) + { + fprintf(stdout,"The dongle was not detected in bootloader mode, "\ + "now \ntrying to set it with a command.\n"); + } fux_connect(); /* Enter bootloader mode. */ ret = usb_send_commands(dev_h, send_data, 5); @@ -296,7 +334,10 @@ sleep(2); } else + { fprintf (stderr, "Switching to bootloader mode failed.\n"); + return 1; + } } @@ -340,7 +381,7 @@ /* Checking path */ len = strlen(path); if (path[len-1] != '/') - strcat(path, "/"); /* Append '/' at the end of not specified. */ + strcat(path, "/"); /* Append '/' at the end if not specified. */ strcpy (filenamepath, path); strcat(filenamepath, filename); filename = filenamepath; @@ -417,7 +458,7 @@ /* Remember the name of the program, to incorporate in messages. The name is stored in argv[0]. */ - program_name = argv[0]; + /*program_name = argv[0];*/ /* Save the start time to measure the programming time */ start_time = time((time_t *)0); @@ -456,7 +497,7 @@ verbose = 1; break; case 'V': /* -V or --version */ - fprintf(stdout, "%s v%s, an uploader program for tuxdroid\n\n",program_name, program_version ); + fprintf(stdout, "%s %s, an uploader program for tuxdroid.\n\n",program_name, program_version ); exit(0); /* version is already printed, so just exit. */ break; case '?': /* The user specified an invalid option. */ @@ -470,12 +511,10 @@ } } while (next_option != -1); - /* Done with options. OPTIND points to first nonoption argument. - For demonstration purposes, print them if the verbose option was - specified. */ + /* Done with options. OPTIND points to first nonoption argument. */ /* Print program name and version at program launch */ - if (verbose) fprintf(stdout, "%s v%s, an uploader program for tuxdroid\n\n",program_name, program_version ); + if (verbose) fprintf(stdout, "%s %s, an uploader program for tuxdroid.\n\n",program_name, program_version ); /* If no program mode has been selected, choose INPUTFILES. */ if (program_mode == NONE) Modififirmware/tuxup/trunk/version.h =================================================================== --- firmware/tuxup/trunk/version.h 2007-03-26 06:08:50 UTC (rev 210) +++ firmware/tuxup/trunk/version.h 2007-03-27 11:04:28 UTC (rev 211) @@ -22,6 +22,6 @@ #ifndef version_h #define version_h -#define VERSION "0.1.0" +#define VERSION "0.1.1 (SVN/UNRELEASED)" #endif |
From: <c2m...@c2...> - 2007-03-26 09:33:54
|
Author: jaguarondi Date: 2007-03-26 08:05:18 +0200 (lun, 26 mar 2007) New Revision: 206 Modified: firmware/tuxup/trunk/main.c Log: - BUG: segfault when the given filename didn't have an extension Modififirmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-03-26 06:04:11 UTC (rev 205) +++ firmware/tuxup/trunk/main.c 2007-03-26 06:05:18 UTC (rev 206) @@ -347,42 +347,45 @@ filename = filenamepath; } if (verbose) printf ("Processing: %s\n", filename); + extension = strrchr(filename, '.'); - - /* Check which program function to start. */ - if (!strcmp(extension, ".hex")) + if (extension) /* check that an extension has been given */ { - int i, usb = 0; - /* Check for 'fuxusb' hex file. */ - len = strlen(filename); - for (i=0; i< len-7; i++) + /* Check which program function to start. */ + if (!strcmp(extension, ".hex")) { - if (!strncmp(filename+i, "fuxusb", 6)) + int i, usb = 0; + /* Check for 'fuxusb' hex file. */ + len = strlen(filename); + for (i=0; i< len-7; i++) { - ret = prog_usb(filename); - usb = 1; - break; + if (!strncmp(filename+i, "fuxusb", 6)) + { + ret = prog_usb(filename); + usb = 1; + break; + } } + if (!usb) /* AVR hex file. */ + ret = prog_flash(filename); } - if (!usb) /* AVR hex file. */ - ret = prog_flash(filename); - } - else if (!strcmp(extension, ".eep")) - { - int i; - len = strlen(filename); - for (i=0; i< len-7; i++) + else if (!strcmp(extension, ".eep")) { - if (!strncmp(filename+i, "tuxcore", 7)) + int i; + len = strlen(filename); + for (i=0; i< len-7; i++) { - ret = prog_eeprom(TUXCORE_CPU_NUM, filename); - break; + if (!strncmp(filename+i, "tuxcore", 7)) + { + ret = prog_eeprom(TUXCORE_CPU_NUM, filename); + break; + } + else if (!strncmp(filename+i, "tuxaudio", 7)) + { + ret = prog_eeprom(TUXAUDIO_CPU_NUM, filename); + break; + } } - else if (!strncmp(filename+i, "tuxaudio", 7)) - { - ret = prog_eeprom(TUXAUDIO_CPU_NUM, filename); - break; - } } } if (ret == -1) fprintf(stderr, "%s is not a valid programming file.\n", filename); |
From: <c2m...@c2...> - 2007-03-26 09:33:44
|
Author: jaguarondi Date: 2007-03-26 08:02:45 +0200 (lun, 26 mar 2007) New Revision: 204 Modified: daemon/tags/0.2.0-alpha1/ daemon/tags/0.2.0-alpha2/ daemon/tags/0.2.0/ daemon/trunk/ firmware/tuxaudio/trunk/ firmware/tuxcore/trunk/ firmware/tuxup/trunk/ Log: moved all externals to the new repository at http://svn.tuxisalive.com Property changes on: daemon/tags/0.2.0 ___________________________________________________________________ Nom : svn:externals - tuxdefs https://svn.kysoh.com/firmware/tuxdefs + tuxdefs http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: daemon/tags/0.2.0-alpha1 ___________________________________________________________________ Nom : svn:externals - tuxdefs https://svn.kysoh.com/firmware/tuxdefs + tuxdefs http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: daemon/tags/0.2.0-alpha2 ___________________________________________________________________ Nom : svn:externals - tuxdefs https://svn.kysoh.com/firmware/tuxdefs + tuxdefs http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: daemon/trunk ___________________________________________________________________ Nom : svn:externals - tuxdefs https://svn.kysoh.com/firmware/tuxdefs + tuxdefs http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: firmware/tuxaudio/trunk ___________________________________________________________________ Nom : svn:externals - common https://svn.kysoh.com/firmware/tuxdefs + common http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: firmware/tuxcore/trunk ___________________________________________________________________ Nom : svn:externals - ./common https://svn.kysoh.com/firmware/tuxdefs + common http://svn.tuxisalive.com/firmware/tuxdefs Property changes on: firmware/tuxup/trunk ___________________________________________________________________ Nom : svn:externals - common https://svn.kysoh.com/firmware/tuxdefs + common http://svn.tuxisalive.com/firmware/tuxdefs |
From: <c2m...@c2...> - 2007-03-26 09:33:38
|
Author: jaguarondi Date: 2007-03-26 08:06:47 +0200 (lun, 26 mar 2007) New Revision: 208 Modified: firmware/tuxup/trunk/bootloader.c Log: - BUG: fixed bug #1 Segfault when a hex file contained a line of data that ended exactly at the end of a segment. The segmnt was never sent to the USB in this case. I'm not sure I didn't created a new bug by changing this, needs more testing. Modififirmware/tuxup/trunk/bootloader.c =================================================================== --- firmware/tuxup/trunk/bootloader.c 2007-03-26 06:06:11 UTC (rev 207) +++ firmware/tuxup/trunk/bootloader.c 2007-03-26 06:06:47 UTC (rev 208) @@ -334,7 +334,9 @@ /* Last segment, fill with '0xFF', send and return */ if (lastSeg) { - //printf("--last segment --\n"); +#if (PRINT_DATA) + printf("--last segment --\n"); +#endif while (parser->currAddr < (parser->segAddr + parser->segLen)) /* fill with '0' until the end of segment */ { fillSegment(parser, 0xFF); @@ -346,7 +348,9 @@ /* resynchronise currAddr and addr */ while(parser->currAddr != parsedData->addr) { - //printf("--synchronisation--\n"); +#if (PRINT_DATA) + printf("--synchronisation--\n"); +#endif if (!parser->inSeg) { parser->currAddr = parsedData->addr & ~(parser->segLen - 1); /* set current address at the segment start by zeroing lower bits */ @@ -364,24 +368,28 @@ while(parser->currAddr < (parsedData->addr + parsedData->dataLen)) { - //printf("--loop--"); +#if (PRINT_DATA) + printf("--loop--"); +#endif if (!parser->inSeg) /* start a new segment if needed */ { - //printf("--new segment--\n"); +#if (PRINT_DATA) + printf("--new segment--\n"); +#endif parser->inSeg = TRUE; parser->segAddr = parser->currAddr; /* set address of the segment start */ startSegment(parser); } + /* store data in segmentData */ + fillSegment(parser, parsedData->data[dataIdx]); + dataIdx++; if (parser->currAddr == (parser->segAddr + parser->segLen)) /* end of segment */ { - //printf("--end segment--"); +#if (PRINT_DATA) + printf("--end segment--"); +#endif finishSegment(parser); } - else /* store data in segmentData */ - { - fillSegment(parser, parsedData->data[dataIdx]); - dataIdx++; - } } return TRUE; |
From: <c2m...@c2...> - 2007-03-26 09:33:36
|
Author: jaguarondi Date: 2007-03-26 08:04:11 +0200 (lun, 26 mar 2007) New Revision: 205 Modified: firmware/tuxup/trunk/main.c Log: - UPD: usage updated with the connection procedure Modififirmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-03-26 06:02:45 UTC (rev 204) +++ firmware/tuxup/trunk/main.c 2007-03-26 06:04:11 UTC (rev 205) @@ -69,10 +69,17 @@ " -v --verbose Print verbose messages.\n" " -V --version Print the version number.\n" "\n" - "'-a' and -'m' options can't be used simultaneously.\n" - "Inputfiles can be specified only if the -a or -m options are not selected.\n" - "Any .hex or .eep files compiled for Tux Droid can be used.\n" - "The eeprom file names should contain 'tuxcore' or 'tuxaudio' in order to be identified, the usb hex file should contain 'fuxusb'.\n" + "Connection: connect the dongle alone, then press on tux's head\n" + " button while switching it on, finally connect the white cable\n" + " between tux and the dongle\n" + "\n" + "Notes: '-a' and -'m' options can't be used simultaneously.\n" + " Inputfiles can be specified only if the -a or -m options are\n" + " not selected.\n" + " Any .hex or .eep files compiled for Tux Droid can be used.\n" + " The eeprom file names should contain 'tuxcore' or 'tuxaudio'\n" + " in order to be identified, the usb hex file should contain\n" + " 'fuxusb'.\n" ); exit (exit_code); } |
From: <c2m...@c2...> - 2007-03-26 09:33:20
|
Author: jaguarondi Date: 2007-03-26 08:06:11 +0200 (lun, 26 mar 2007) New Revision: 207 Modified: firmware/tuxup/trunk/Makefile firmware/tuxup/trunk/main.c firmware/tuxup/trunk/usb-connection.c firmware/tuxup/trunk/usb-connection.h Log: - UPD: forgot to use the CFLAGS in the Makefile, cleaned the code by removing unused variables and avoid any warning. Modififirmware/tuxup/trunk/Makefile =================================================================== --- firmware/tuxup/trunk/Makefile 2007-03-26 06:05:18 UTC (rev 206) +++ firmware/tuxup/trunk/Makefile 2007-03-26 06:06:11 UTC (rev 207) @@ -18,7 +18,7 @@ ## Compile and link tuxup: main.c bootloader.c bootloader.h usb-connection.c usb-connection.h tux-api.h version.h common/commands.h - ${CC} ${LIB} -o tuxup main.c bootloader.c usb-connection.c + ${CC} ${LIB} ${CFLAGS} -o tuxup main.c bootloader.c usb-connection.c clean : -rm -f $(TARGET) *.o Modififirmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-03-26 06:05:18 UTC (rev 206) +++ firmware/tuxup/trunk/main.c 2007-03-26 06:06:11 UTC (rev 207) @@ -147,7 +147,6 @@ FILE *fs = NULL; char word[80]; char hex_nr[3]; - int cpu_nbr, ver_major, ver_minor, ver_update; hex_nr[2]=(char)'\0'; if ((fs = fopen(filename, "r")) == NULL) @@ -271,7 +270,7 @@ int prog_usb(char *filename) { - char send_data[5] = {0x01, 0x01, 0x00, 0x00, 0xFF}; /* XXX include those as defines in commands.h */ + uint8_t send_data[5] = {0x01, 0x01, 0x00, 0x00, 0xFF}; /* XXX include those as defines in commands.h */ char tmp_string[90]; int ret; printf("Programming %s in USB CPU\n", filename); @@ -398,9 +397,7 @@ */ int main(int argc,char *argv[]) { - char path[90], tmp_string[90]; - char *filename; - int arg; + char path[90]; enum program_modes_t program_mode = NONE; time_t start_time, end_time; @@ -487,10 +484,12 @@ if (optind < argc) /* Input files have been given. */ { if (program_mode != INPUTFILES) + { if (argc == optind + 1) strcpy(path, argv[optind]); else usage (stderr, 1); + } } else /* No arguments given. */ usage (stderr, 1); Modififirmware/tuxup/trunk/usb-connection.c =================================================================== --- firmware/tuxup/trunk/usb-connection.c 2007-03-26 06:05:18 UTC (rev 206) +++ firmware/tuxup/trunk/usb-connection.c 2007-03-26 06:06:11 UTC (rev 207) @@ -118,10 +118,10 @@ * \todo Need to define the format of the data array to send and pass it as parameter * \todo Need to add some doc or links about what this status is really */ -int usb_send_commands(usb_dev_handle *dev_h, char *send_data, int size) +int usb_send_commands(usb_dev_handle *dev_h, uint8_t *send_data, int size) { int status; - if((status = usb_interrupt_write(dev_h, USB_W_ENDPOINT, send_data, size, USB_W_TIMEOUT)) < 0) + if((status = usb_interrupt_write(dev_h, USB_W_ENDPOINT, (char*)send_data, size, USB_W_TIMEOUT)) < 0) /* error on usb_interrupt_write() */ { fprintf(stderr, "usb_interrupt_write error: status = %d :: %s \n", status, usb_strerror()); @@ -147,7 +147,7 @@ { int status; - if((status = usb_interrupt_read(dev_h, USB_R_ENDPOINT, receive_data, size, USB_R_TIMEOUT)) < 0) + if((status = usb_interrupt_read(dev_h, USB_R_ENDPOINT, (char*)receive_data, size, USB_R_TIMEOUT)) < 0) { fprintf(stderr, "usb_interrupt_read error: status = %d :: %s \n", status, usb_strerror()); } Modififirmware/tuxup/trunk/usb-connection.h =================================================================== --- firmware/tuxup/trunk/usb-connection.h 2007-03-26 06:05:18 UTC (rev 206) +++ firmware/tuxup/trunk/usb-connection.h 2007-03-26 06:06:11 UTC (rev 207) @@ -65,7 +65,7 @@ usb_dev_handle * usb_open_tux(struct usb_device* dev); struct usb_device* usb_find_tux(); int usb_check_tux_status(usb_dev_handle *dev_h); -int usb_send_commands(usb_dev_handle *dev_h, char *send_data, int size); +int usb_send_commands(usb_dev_handle *dev_h, uint8_t *send_data, int size); int usb_get_commands(usb_dev_handle *dev_h, uint8_t *receive_data, int size); #endif /* USB_CONNECTION_H */ |
From: <c2m...@c2...> - 2007-03-26 09:33:01
|
Author: jaguarondi Date: 2007-03-26 08:07:36 +0200 (lun, 26 mar 2007) New Revision: 209 Modified: firmware/tuxup/trunk/CHANGES firmware/tuxup/trunk/TODO firmware/tuxup/trunk/version.h Log: Preparing for release 0.1.0 of tuxup. Modififirmware/tuxup/trunk/CHANGES =================================================================== --- firmware/tuxup/trunk/CHANGES 2007-03-26 06:06:47 UTC (rev 208) +++ firmware/tuxup/trunk/CHANGES 2007-03-26 06:07:36 UTC (rev 209) @@ -7,7 +7,17 @@ ---------------------------------------------------------------------- Current: - * Uses interrupt usb requests and not bulk anymore, this is not compatible with the old firmware so to update it, you have to press the belly button when plugging. +0.1.0: + + * BUG: fixed bug #1 Segfault when a hex file contained a line of data that + ended exactly at the end of a segment. The segmnt was never sent to the USB + in this case. + * Use CFLAGS in the Makefile, cleaned the code by removing unused variables + and avoid any warning. + * BUG: segfault when the given filename didn't have an extension. + * Uses interrupt usb requests and not bulk anymore, this is not compatible + with the old firmware so to update it, you have to press the belly button + when plugging. * Connection now checks for 5 seconds before claiming that tux is not found. * Added autodetection of the CPU to be programmed based on the CPU field in hex files or names of eep files. @@ -15,7 +25,8 @@ * Changed the usage, replaced the old argument parsing with getopt. * Added --version, --help, --pretend and --verbose options. * Added --main option to reprogram tuxcore and tuxaudio only. - * Added support for usb programming which is a simple front-end to dfu-programmer. dfu-programmer needs to be installed. + * Added support for usb programming which is a simple front-end to + dfu-programmer. dfu-programmer needs to be installed. * Now uses defines from commands.h for CPU numbers, I2C addresses, etc. * Code cleanup Modififirmware/tuxup/trunk/TODO =================================================================== --- firmware/tuxup/trunk/TODO 2007-03-26 06:06:47 UTC (rev 208) +++ firmware/tuxup/trunk/TODO 2007-03-26 06:07:36 UTC (rev 209) @@ -4,7 +4,7 @@ - Add man page -- Add install and uninstall options in the make file +- Add install and uninstall options in the make file or use autoconf - Display the usb firmware version programmed in the dongle and in the hex file like all other CPU's, need to change the firmware for that Modififirmware/tuxup/trunk/version.h =================================================================== --- firmware/tuxup/trunk/version.h 2007-03-26 06:06:47 UTC (rev 208) +++ firmware/tuxup/trunk/version.h 2007-03-26 06:07:36 UTC (rev 209) @@ -22,6 +22,6 @@ #ifndef version_h #define version_h -#define VERSION "0.0.1" +#define VERSION "0.1.0" #endif |
From: <c2m...@c2...> - 2007-03-26 09:31:00
|
Author: jaguarondi Date: 2007-03-26 08:08:50 +0200 (lun, 26 mar 2007) New Revision: 210 Added: firmware/tuxup/tags/0.1.0/ Log: - TAG: tuxup release 0.1.0 Copi firmware/tuxup/tags/0.1.0 (de rsion 209, firmware/tuxup/trunk) |
From: jaguarondi <c2m...@c2...> - 2007-03-23 14:48:40
|
Author: jaguarondi Date: 2007-03-23 15:48:01 +0100 (Fri, 23 Mar 2007) New Revision: 209 Added: firmware/tuxup/tags/0.1.0/ Log: - TAG: tuxup release 0.1.0 Copied: firmware/tuxup/tags/0.1.0 (from rev 208, firmware/tuxup/trunk) |
From: jaguarondi <c2m...@c2...> - 2007-03-23 14:47:54
|
Author: jaguarondi Date: 2007-03-23 15:47:10 +0100 (Fri, 23 Mar 2007) New Revision: 208 Modified: firmware/tuxup/trunk/CHANGES firmware/tuxup/trunk/TODO firmware/tuxup/trunk/version.h Log: Preparing for release 0.1.0 of tuxup. Modified: firmware/tuxup/trunk/CHANGES =================================================================== --- firmware/tuxup/trunk/CHANGES 2007-03-23 02:08:57 UTC (rev 207) +++ firmware/tuxup/trunk/CHANGES 2007-03-23 14:47:10 UTC (rev 208) @@ -7,7 +7,17 @@ ---------------------------------------------------------------------- Current: - * Uses interrupt usb requests and not bulk anymore, this is not compatible with the old firmware so to update it, you have to press the belly button when plugging. +0.1.0: + + * BUG: fixed bug #1 Segfault when a hex file contained a line of data that + ended exactly at the end of a segment. The segmnt was never sent to the USB + in this case. + * Use CFLAGS in the Makefile, cleaned the code by removing unused variables + and avoid any warning. + * BUG: segfault when the given filename didn't have an extension. + * Uses interrupt usb requests and not bulk anymore, this is not compatible + with the old firmware so to update it, you have to press the belly button + when plugging. * Connection now checks for 5 seconds before claiming that tux is not found. * Added autodetection of the CPU to be programmed based on the CPU field in hex files or names of eep files. @@ -15,7 +25,8 @@ * Changed the usage, replaced the old argument parsing with getopt. * Added --version, --help, --pretend and --verbose options. * Added --main option to reprogram tuxcore and tuxaudio only. - * Added support for usb programming which is a simple front-end to dfu-programmer. dfu-programmer needs to be installed. + * Added support for usb programming which is a simple front-end to + dfu-programmer. dfu-programmer needs to be installed. * Now uses defines from commands.h for CPU numbers, I2C addresses, etc. * Code cleanup Modified: firmware/tuxup/trunk/TODO =================================================================== --- firmware/tuxup/trunk/TODO 2007-03-23 02:08:57 UTC (rev 207) +++ firmware/tuxup/trunk/TODO 2007-03-23 14:47:10 UTC (rev 208) @@ -4,7 +4,7 @@ - Add man page -- Add install and uninstall options in the make file +- Add install and uninstall options in the make file or use autoconf - Display the usb firmware version programmed in the dongle and in the hex file like all other CPU's, need to change the firmware for that Modified: firmware/tuxup/trunk/version.h =================================================================== --- firmware/tuxup/trunk/version.h 2007-03-23 02:08:57 UTC (rev 207) +++ firmware/tuxup/trunk/version.h 2007-03-23 14:47:10 UTC (rev 208) @@ -22,6 +22,6 @@ #ifndef version_h #define version_h -#define VERSION "0.0.1" +#define VERSION "0.1.0" #endif |