# HG changeset patch # User etisserant # Date 1155069272 -7200 # Node ID e70439f505396363b1df43034c3ada44756efccd # Parent ddeeb217ed71df89f91f3c21e9afe0481e7c86d8 First working cygwin/pcan_light commit. can_peak_win32.c is obfuscated. diff -r ddeeb217ed71 -r e70439f50539 configure --- a/configure Fri Jun 23 16:32:42 2006 +0200 +++ b/configure Tue Aug 08 22:34:32 2006 +0200 @@ -442,14 +442,23 @@ fi if [ "$SUB_CAN_DRIVER" = "peak_win32" ]; then - if [ "PCAN_HEADER" = "" -o "PCAN_LIB" = "" ]; then + if [ "$PCAN_HEADER" = "" -o "PCAN_LIB" = "" ]; then echo "!!! ERROR !!! Please set PCAN_LIB PCAN_HEADER [PCAN_INCLUDE] to appropriate paths ! " fi SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -liberty\ \'$PCAN_LIB\' - if [ "$PCAN_INCLUDE" != "" ]; then - SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -I$PCAN_INCLUDE - fi - SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ \'-DPCAN_HEADER_=\"$PCAN_HEADER\"\' + echo "Converting PcanLib header files for gcc -> /drivers/can_peak_win32/cancfg.h" + cat include/can_peak_win32/cancfg.h.head $PCAN_INCLUDE/$PCAN_HEADER > include/can_peak_win32/cancfg.h + # second port handling + if [ "$PCAN2_HEADER" != "" ]; then + echo "Stripping down second Pcan Light header " + echo >> include/can_peak_win32/cancfg.h + echo "// Stripped PcanLight header to prevent typedef conflicts ">> include/can_peak_win32/cancfg.h + echo >> include/can_peak_win32/cancfg.h + grep __stdcall $PCAN_INCLUDE/$PCAN2_HEADER >> include/can_peak_win32/cancfg.h + SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ \'$PCAN2_LIB\' + fi + echo '#define PCAN2_HEADER_' >> include/can_peak_win32/cancfg.h + cat include/can_peak_win32/cancfg.h.tail >> include/can_peak_win32/cancfg.h fi if [ "$SUB_CAN_DRIVER" = "none" ]; then diff -r ddeeb217ed71 -r e70439f50539 drivers/can_peak_win32/.cvsignore --- a/drivers/can_peak_win32/.cvsignore Fri Jun 23 16:32:42 2006 +0200 +++ b/drivers/can_peak_win32/.cvsignore Tue Aug 08 22:34:32 2006 +0200 @@ -1,1 +1,2 @@ Makefile +obf diff -r ddeeb217ed71 -r e70439f50539 drivers/can_peak_win32/Makefile.in --- a/drivers/can_peak_win32/Makefile.in Fri Jun 23 16:32:42 2006 +0200 +++ b/drivers/can_peak_win32/Makefile.in Tue Aug 08 22:34:32 2006 +0200 @@ -54,6 +54,15 @@ rm -f $(TARGET_HFILES) clean: - -\rm $(OBJS) + rm -f $(OBJS) mrproper: clean + +#********** make obfuscated translation ************************************* +.PHONY : obfuscate +obfuscate: + cobf -p obf/pp_gnu -o obf -c can_peak_win32.c -t obf/tlist.tok -m obf/mlist.tok -x pcan_ obf/can_peak_win32_org.c;\ + cat obf/can_peak_win32.c.header obf/can_peak_win32.c > can_peak_win32.c;\ + cat obf/cobf.h.header obf/cobf.h > cobf.h;\ + rm -f obf/can_peak_win32.c obf/cobf.h obf/cobf.log obf/uncobf.h + diff -r ddeeb217ed71 -r e70439f50539 drivers/can_peak_win32/can_peak_win32.c --- a/drivers/can_peak_win32/can_peak_win32.c Fri Jun 23 16:32:42 2006 +0200 +++ b/drivers/can_peak_win32/can_peak_win32.c Tue Aug 08 22:34:32 2006 +0200 @@ -1,166 +1,114 @@ /* -This file is part of CanFestival, a library implementing CanOpen Stack. -Copyright (C): Edouard TISSERANT and Francis DUPIN +This file is not part of CanFestival. +This is third party contributed file. -See COPYING file for copyrights details. +It is provided as-this and without any warranty -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include /* for NULL */ -#include -#include -#include -#include -#include +//**************************************************************************** +// Copyright (C) 2006 PEAK System-Technik GmbH +// +// linux@peak-system.com +// www.peak-system.com +// +// This part of software is proprietary. It is allowed to +// distribute it with CanFestival. +// +// No warranty at all is given. +// +// Maintainer(s): Edouard TISSERANT (edouard.tisserant@lolitech.fr) +//**************************************************************************** -/* driver pcan pci for Peak board */ -//#include "libpcan.h" -//#include "pcan.h" - -#include -#include "timer.h" -#include "can_driver.h" -#include "timers_driver.h" - -#define MAX_NB_CAN_PORTS 1 - -typedef struct { - char used; - TASK_HANDLE receiveTask; - CO_Data* d; -} CANPort; - -CANPort canports[MAX_NB_CAN_PORTS] = {{0,},}; - -// Define for rtr CAN message -#define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR - -/*********functions which permit to communicate with the board****************/ -UNS8 canReceive(CAN_HANDLE fd0, Message *m) -{ - UNS8 data; - TPCANMsg peakMsg; - if ((errno = CAN_Read(& peakMsg))) { // Blocks until no new message or error. - perror("!!! Peak board : error of reading. (from f_can_receive function) \n"); - return 1; - } - m->cob_id.w = peakMsg.ID; - if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST) /* bits of MSGTYPE_*/ - m->rtr = 0; - else - m->rtr = 1; - m->len = peakMsg.LEN; /* count of data bytes (0..8) */ - for(data = 0 ; data < peakMsg.LEN ; data++) - m->data[data] = peakMsg.DATA[data]; /* data bytes, up to 8 */ - - return 0; -} - -void canReceiveLoop(CAN_HANDLE fd0) -{ - CO_Data* d = ((CANPort*)fd0)->d; - Message m; - while (1) { - if(!canReceive(fd0, &m)) - { - EnterMutex(); - canDispatch(d, &m); - LeaveMutex(); - }else{ -// printf("canReceive returned error\n"); - break; - } - } -} - -/***************************************************************************/ -UNS8 canSend(CAN_HANDLE fd0, Message *m) -{ - UNS8 data; - TPCANMsg peakMsg; - peakMsg.ID=m -> cob_id.w; /* 11/29 bit code */ - if(m->rtr == 0) - peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_*/ - else { - peakMsg.MSGTYPE = CAN_INIT_TYPE_ST_RTR; /* bits of MSGTYPE_*/ - } - peakMsg.LEN = m->len; - /* count of data bytes (0..8) */ - for(data = 0 ; data < m->len; data ++) - peakMsg.DATA[data] = m->data[data]; /* data bytes, up to 8 */ - - if((errno = CAN_Write(& peakMsg))) { - perror("!!! Peak board : error of writing. (from canSend function) \n"); - return 1; - } - return 0; - -} - -/***************************************************************************/ -CAN_HANDLE canOpen(s_BOARD *board) -{ - HANDLE fd0 = NULL; - char busname[64]; - char* pEnd; - int i; - - for(i=0; i < MAX_NB_CAN_PORTS; i++) - { - if(!canports[i].used) - break; - } - if(canports[i].used) - { - perror("can_peak_win32.c: no more can port available with this pcan library\n"); - perror("can_peak_win32.c: please link another executable with another pcan lib\n"); - return NULL; - } -// if(strtol(board->busname, &pEnd,0) >= 0) -// { -// sprintf(busname,"/dev/pcan%s",board->busname); -// fd0 = LINUX_CAN_Open(busname, O_RDWR); -// } - - if (i==MAX_NB_CAN_PORTS || fd0 == NULL) - { - fprintf (stderr, "Open failed.\n"); - return (CAN_HANDLE)NULL; - } - - CAN_Init(board->baudrate, CAN_INIT_TYPE_ST); - - canports[i].used = 1; - - canports[i].d = board->d; - CreateReceiveTask((CANPort*) &canports[i], &canports[i].receiveTask); - - return (CANPort*) &canports[i]; -} - -/***************************************************************************/ -int canClose(CAN_HANDLE fd0) -{ - CAN_Close(); - ((CANPort*)fd0)->used = 0; - WaitReceiveTaskEnd(&((CANPort*)fd0)->receiveTask); - return 0; -} +/* + Obfuscated by COBF (Version 1.06 2006-01-07 by BB) at Tue Aug 8 23:36:30 2006 +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include"timer.h" +#include"can_driver.h" +#include"timers_driver.h" +#include"cobf.h" +#ifndef extra_PCAN_init_params +#define extra_PCAN_init_params +#endif +#ifdef PCAN2_HEADER_ +#define pcan_s 2 +#else +#define pcan_s 1 +#endif +pcan_34 pcan_51{pcan_9 pcan_r;pcan_39 pcan_1;pcan_24*pcan_o;pcan_16* +pcan_k;}pcan_c;pcan_c pcan_g[pcan_s]={{0,},};pcan_47 pcan_l=pcan_38; +pcan_12 pcan_x(pcan_n pcan_b){ +#ifdef PCAN2_HEADER_ +pcan_d(pcan_g!=((pcan_c* )pcan_b))pcan_52(((pcan_c* )pcan_b)->pcan_k +->pcan_20,pcan_v extra_PCAN_init_params);pcan_j +#endif +pcan_54(((pcan_c* )pcan_b)->pcan_k->pcan_20,pcan_v +extra_PCAN_init_params);}pcan_t pcan_17(pcan_n pcan_b,pcan_4*pcan_e){ +pcan_t pcan_f;pcan_23 pcan_a;pcan_11 pcan_i;pcan_22(&pcan_l); +#ifdef PCAN2_HEADER_ +pcan_d(pcan_g!=((pcan_c* )pcan_b))pcan_i=pcan_27(&pcan_a);pcan_j +#endif +pcan_i=pcan_48(&pcan_a);pcan_d(pcan_i==pcan_w){pcan_d(pcan_a.pcan_q&~ +(pcan_14|pcan_10)){pcan_d(pcan_a.pcan_q==pcan_25){pcan_7("\x21\x21" +"\x21\x20\x50\x65\x61\x6b\x20\x62\x6f\x61\x72\x64\x20\x72\x65\x61\x64" +"\x20\x3a\x20\x72\x65\x2d\x69\x6e\x69\x74\n");pcan_x(pcan_b);pcan_y( +10000);}pcan_u(&pcan_l);pcan_p pcan_a.pcan_q==pcan_28?pcan_a.pcan_8[2 +]:pcan_46;}pcan_e->pcan_13.pcan_15=pcan_a.pcan_18;pcan_d(pcan_a. +pcan_q==pcan_v)pcan_e->pcan_2=0;pcan_j pcan_e->pcan_2=1;pcan_e-> +pcan_z=pcan_a.pcan_6;pcan_3(pcan_f=0;pcan_fpcan_f[pcan_f]=pcan_a.pcan_8[pcan_f];}pcan_u(&pcan_l);pcan_p pcan_i +;}pcan_12 pcan_44(pcan_n pcan_b){pcan_24*pcan_o=((pcan_c* )pcan_b)-> +pcan_o;pcan_4 pcan_e;pcan_19(((pcan_c* )pcan_b)->pcan_r){pcan_11 +pcan_i;pcan_d((pcan_i=pcan_17(pcan_b,&pcan_e))==pcan_w){pcan_26(); +pcan_50(pcan_o,&pcan_e);pcan_30();}pcan_j{pcan_d(!(pcan_i&pcan_31|| +pcan_i&pcan_40||pcan_i&pcan_45)){pcan_7("\x63\x61\x6e\x52\x65\x63\x65" +"\x69\x76\x65\x20\x72\x65\x74\x75\x72\x6e\x65\x64\x20\x65\x72\x72\x6f" +"\x72\x20\x28\x25\x64\x29\n",pcan_i);}pcan_y(1000);}}}pcan_t pcan_41( +pcan_n pcan_b,pcan_4*pcan_e){pcan_t pcan_f;pcan_23 pcan_a;pcan_a. +pcan_18=pcan_e->pcan_13.pcan_15;pcan_d(pcan_e->pcan_2==0)pcan_a. +pcan_q=pcan_v;pcan_j{pcan_a.pcan_q=pcan_14|pcan_10;}pcan_a.pcan_6= +pcan_e->pcan_z;pcan_3(pcan_f=0;pcan_fpcan_z;pcan_f++)pcan_a. +pcan_8[pcan_f]=pcan_e->pcan_f[pcan_f];pcan_m=pcan_w;pcan_32{pcan_22(& +pcan_l); +#ifdef PCAN2_HEADER_ +pcan_d(pcan_g!=((pcan_c* )pcan_b))pcan_m=pcan_53(&pcan_a);pcan_j +#endif +pcan_m=pcan_43(&pcan_a);pcan_d(pcan_m){pcan_d(pcan_m==pcan_25){pcan_7 +("\x21\x21\x21\x20\x50\x65\x61\x6b\x20\x62\x6f\x61\x72\x64\x20\x77" +"\x72\x69\x74\x65\x20\x3a\x20\x72\x65\x2d\x69\x6e\x69\x74\n");pcan_x( +pcan_b);pcan_y(10000);}pcan_u(&pcan_l);pcan_y(100);}pcan_j{pcan_u(& +pcan_l);}}pcan_19(pcan_m!=pcan_w&&((pcan_c* )pcan_b)->pcan_r);pcan_p 0 +;}pcan_n pcan_42(pcan_16*pcan_k){pcan_9 pcan_55[64];pcan_9*pcan_36; +pcan_21 pcan_h;pcan_3(pcan_h=0;pcan_hpcan_o; +pcan_x((pcan_c* )&pcan_g[pcan_h]);pcan_29((pcan_c* )&pcan_g[pcan_h],& +pcan_g[pcan_h].pcan_1);pcan_p(pcan_c* )&pcan_g[pcan_h];}pcan_21 +pcan_57(pcan_n pcan_b){((pcan_c* )pcan_b)->pcan_r=0; +#ifdef PCAN2_HEADER_ +pcan_d(pcan_g!=((pcan_c* )pcan_b))pcan_49();pcan_j +#endif +pcan_35();pcan_33(&((pcan_c* )pcan_b)->pcan_1);pcan_p 0;} diff -r ddeeb217ed71 -r e70439f50539 drivers/can_peak_win32/cobf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drivers/can_peak_win32/cobf.h Tue Aug 08 22:34:32 2006 +0200 @@ -0,0 +1,97 @@ +/* + +This file is not part of CanFestival. +This is third party contributed file. + +It is provided as-this and without any warranty + +*/ + +//**************************************************************************** +// Copyright (C) 2006 PEAK System-Technik GmbH +// +// linux@peak-system.com +// www.peak-system.com +// +// This part of software is proprietary. It is allowed to +// distribute it with CanFestival. +// +// No warranty at all is given. +// +// Maintainer(s): Edouard TISSERANT (edouard.tisserant@lolitech.fr) +//**************************************************************************** + +/* + Obfuscated by COBF (Version 1.06 2006-01-07 by BB) at Tue Aug 8 23:36:30 2006 +*/ +#define pcan_34 typedef +#define pcan_51 struct +#define pcan_9 char +#define pcan_39 TASK_HANDLE +#define pcan_1 receiveTask +#define pcan_24 CO_Data +#define pcan_o d +#define pcan_16 s_BOARD +#define pcan_k board +#define pcan_47 pthread_mutex_t +#define pcan_38 PTHREAD_MUTEX_INITIALIZER +#define pcan_12 void +#define pcan_n CAN_HANDLE +#define pcan_d if +#define pcan_52 CAN2_Init +#define pcan_20 baudrate +#define pcan_v CAN_INIT_TYPE_ST +#define pcan_j else +#define pcan_54 CAN_Init +#define pcan_t UNS8 +#define pcan_17 canReceive +#define pcan_4 Message +#define pcan_f data +#define pcan_23 TPCANMsg +#define pcan_11 DWORD +#define pcan_22 pthread_mutex_lock +#define pcan_27 CAN2_Read +#define pcan_48 CAN_Read +#define pcan_w CAN_ERR_OK +#define pcan_q MSGTYPE +#define pcan_14 MSGTYPE_STANDARD +#define pcan_10 MSGTYPE_RTR +#define pcan_25 CAN_ERR_BUSOFF +#define pcan_7 printf +#define pcan_y usleep +#define pcan_u pthread_mutex_unlock +#define pcan_p return +#define pcan_28 MSGTYPE_STATUS +#define pcan_8 DATA +#define pcan_46 CAN_ERR_OVERRUN +#define pcan_13 cob_id +#define pcan_15 w +#define pcan_18 ID +#define pcan_2 rtr +#define pcan_z len +#define pcan_6 LEN +#define pcan_3 for +#define pcan_44 canReceiveLoop +#define pcan_19 while +#define pcan_26 EnterMutex +#define pcan_50 canDispatch +#define pcan_30 LeaveMutex +#define pcan_31 CAN_ERR_QRCVEMPTY +#define pcan_40 CAN_ERR_BUSLIGHT +#define pcan_45 CAN_ERR_BUSHEAVY +#define pcan_41 canSend +#define pcan_m errno +#define pcan_32 do +#define pcan_53 CAN2_Write +#define pcan_43 CAN_Write +#define pcan_42 canOpen +#define pcan_21 int +#define pcan_56 break +#define pcan_0 fprintf +#define pcan_5 stderr +#define pcan_37 NULL +#define pcan_29 CreateReceiveTask +#define pcan_57 canClose +#define pcan_49 CAN2_Close +#define pcan_35 CAN_Close +#define pcan_33 WaitReceiveTaskEnd diff -r ddeeb217ed71 -r e70439f50539 include/can_peak_win32/cancfg.h --- a/include/can_peak_win32/cancfg.h Fri Jun 23 16:32:42 2006 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* -This file is part of CanFestival, a library implementing CanOpen Stack. - -Copyright (C): Edouard TISSERANT and Francis DUPIN - -See COPYING file for copyrights details. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __CANCFG_H__ -#define __CANCFG_H__ - -#include -//#include "Pcan_usb.h" -#include PCAN_HEADER_ -#define CAN_HANDLE void* - -#endif diff -r ddeeb217ed71 -r e70439f50539 include/can_peak_win32/cancfg.h.head --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/can_peak_win32/cancfg.h.head Tue Aug 08 22:34:32 2006 +0200 @@ -0,0 +1,32 @@ +/* +This file is part of CanFestival, a library implementing CanOpen Stack. + +Copyright (C): Edouard TISSERANT and Francis DUPIN + +See COPYING file for copyrights details. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __CANCFG_H__ +#define __CANCFG_H__ + +#include + +// Following part of the file is copied by configure script +// from choosen PcanLight header file +//------------------------------------------------------------------------------- +//------------------------------------------------------------------------------- +//------------------------------------------------------------------------------- diff -r ddeeb217ed71 -r e70439f50539 include/can_peak_win32/cancfg.h.tail --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/can_peak_win32/cancfg.h.tail Tue Aug 08 22:34:32 2006 +0200 @@ -0,0 +1,7 @@ +//------------------------------------------------------------------------------- +//------------------------------------------------------------------------------- +//------------------------------------------------------------------------------- + +#define CAN_HANDLE void* + +#endif