├── .gitignore ├── CMakeLists.txt ├── test ├── df1d └── test.php ├── src ├── write_float.c ├── write_integer.c ├── read_float.c ├── read_integer.c ├── read_boolean.c ├── write_boolean.c ├── write_AB.c ├── read_A2.c ├── write_AA.c ├── read_socket.c ├── main.c ├── select_fnct.c ├── common.c ├── server.c ├── calc_address.c ├── df1.h ├── serial.c └── df1.c ├── README └── Makefile /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeFiles/ 2 | bin/ 3 | cmake_install.cmake 4 | CMakeCache.txt 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | #Déclaration du projet 4 | project(df1) 5 | set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE}) 6 | 7 | #Génération de la liste des fichiers sources 8 | file( 9 | GLOB_RECURSE 10 | source_files 11 | src/* 12 | ) 13 | 14 | #Déclaration de l'exécutable 15 | add_executable( 16 | df1 17 | ${source_files} 18 | ) 19 | -------------------------------------------------------------------------------- /test/df1d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chkconfig: 2345 80 90 4 | # description: Server df1 for SLC500 AB PLC 5 | 6 | PATH=/sbin:/bin:/usr/sbin:/usr/bin 7 | export PATH 8 | 9 | # Source function library. 10 | #. /etc/rc.d/init.d/functions 11 | 12 | # See how we are called. 13 | case "$1" in 14 | start) 15 | printf "Starting df1 server...\n" 16 | df1 17 | echo "" 18 | ;; 19 | stop) 20 | PID=`pidof -s df1` 21 | if [ "$PID" ]; then 22 | printf "Stopping df1 server...\n" 23 | kill -3 $PID 24 | fi 25 | echo "" 26 | ;; 27 | restart) 28 | $0 stop 29 | $0 start 30 | ;; 31 | *) 32 | printf "Usage: df1 {start|stop|restart}\n" 33 | exit 1 34 | esac 35 | 36 | -------------------------------------------------------------------------------- /src/write_float.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int write_float(int plctype, char *straddress, float *value) 21 | { 22 | int error=ERROR_WRITE; 23 | TThree_Address_Fields address; 24 | 25 | if ((error = calc_address(straddress,&address))!=SUCCES) 26 | return error; 27 | if (plctype==SLC) 28 | error=write_AA(address,value,sizeof(*value)); 29 | return error; 30 | } 31 | -------------------------------------------------------------------------------- /src/write_integer.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int write_integer(int plctype, char *straddress, word *value) 21 | { 22 | int error=ERROR_WRITE; 23 | TThree_Address_Fields address; 24 | 25 | if ((error = calc_address(straddress,&address))!=SUCCES) 26 | return error; 27 | if (plctype==SLC) 28 | error=write_AA(address,value,sizeof(*value)); 29 | return error; 30 | } 31 | -------------------------------------------------------------------------------- /src/read_float.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int read_float(int plctype, char *straddress, float *value) 21 | { 22 | int error=ERROR_READ_INTEGER; 23 | TThree_Address_Fields address; 24 | 25 | *value=0;//init to 0 26 | if ((error = calc_address(straddress,&address))!=SUCCES) 27 | return error; 28 | if (plctype==SLC) 29 | error=read_A2(address,value,sizeof(*value)); 30 | return error; 31 | } 32 | -------------------------------------------------------------------------------- /src/read_integer.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int read_integer(int plctype, char *straddress, word *value) 21 | { 22 | int error=ERROR_READ_INTEGER; 23 | TThree_Address_Fields address; 24 | 25 | *value=0;//init to 0 26 | if ((error = calc_address(straddress,&address))!=SUCCES) 27 | return error; 28 | if (plctype==SLC) 29 | error=read_A2(address,value,sizeof(*value)); 30 | return error; 31 | } 32 | -------------------------------------------------------------------------------- /src/read_boolean.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int read_boolean(int plctype, char *straddress, int *value) 21 | { 22 | int error=ERROR_READ_INTEGER; 23 | TThree_Address_Fields address; 24 | byte posit; 25 | int temp=1; 26 | int tempvalue; 27 | 28 | tempvalue=0;//init to 0 29 | if ((error = calc_address(straddress,&address))!=SUCCES) 30 | return error; 31 | posit=address.s_eleNumber; 32 | address.s_eleNumber=0; 33 | if (plctype==SLC) 34 | error=read_A2(address,&tempvalue,sizeof(tempvalue)); 35 | *value=(temp&(tempvalue>>posit)); 36 | return error; 37 | } 38 | -------------------------------------------------------------------------------- /src/write_boolean.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) h 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | //********************************************************* 20 | int write_boolean(int plctype, char *straddress, int *value) 21 | { 22 | int error=ERROR_READ_INTEGER; 23 | TThree_Address_Fields address; 24 | byte posit; 25 | word valuebool; 26 | word mask; 27 | 28 | if ((error = calc_address(straddress,&address))!=SUCCES) 29 | return error; 30 | posit=address.s_eleNumber; 31 | if (plctype==SLC){ 32 | mask = 0x0001< 2 | 3 | TEST 4 | 5 | 6 | 7 | Test DF1



8 | "; 39 | echo "
"; 40 | echo "F8:0=".floatval(readSLC('F8:0'))."
"; 41 | echo "
"; 42 | echo "F8:1=".floatval(readSLC('F8:1'))."
"; 43 | echo "
"; 44 | echo "F8:2=".floatval(readSLC('F8:2'))."
"; 45 | echo "
"; 46 | echo "
"; 47 | 48 | echo "N7:4= ".readSLC('n7:4')."
"; 49 | //echo "write N7:4=10".writeSLC('n7:4','10')."
"; 50 | echo "
"; 51 | 52 | socket_close( $socket ); 53 | 54 | ?> 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/write_AB.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern word tns; 20 | 21 | /***********************************************************************/ 22 | /* Cmd:0F Fnc:AB > write W/4 fields & mask in SLC500 */ 23 | /* Write 1 bit in SLC */ 24 | /***********************************************************************/ 25 | int write_AB(TThree_Address_Fields address, word value, word mask) 26 | { 27 | TCmd4 cmd; 28 | TMsg sendMsg,rcvMsg; 29 | int error=ERROR_WRITE_AB; 30 | 31 | bzero(&sendMsg,sizeof(sendMsg)); 32 | bzero(&rcvMsg,sizeof(rcvMsg)); 33 | bzero(&cmd,sizeof(cmd)); 34 | sendMsg.dst = DEST; 35 | sendMsg.src = SOURCE; 36 | sendMsg.cmd = 0x0F; 37 | sendMsg.sts = 0x00; 38 | sendMsg.tns = ++tns; 39 | cmd.fnc = 0xAB; 40 | cmd.size = address.size; 41 | cmd.fileNumber = address.fileNumber; 42 | cmd.fileType = address.fileType; 43 | cmd.eleNumber = address.eleNumber; 44 | cmd.s_eleNumber = 0x00; 45 | cmd.maskbyte = mask; 46 | cmd.value = value; 47 | memcpy(&sendMsg.data,&cmd,sizeof(cmd)); 48 | sendMsg.size = sizeof(cmd); 49 | if ((error=send_DF1(sendMsg))!=0) 50 | return error; 51 | if ((error=rcv_DF1(&rcvMsg))!=0) 52 | return error; 53 | if (rcvMsg.tns!=sendMsg.tns) 54 | return ERROR_TNS_MISMATCH; 55 | if (rcvMsg.sts!=0) 56 | return rcvMsg.sts; 57 | return SUCCES; 58 | } 59 | -------------------------------------------------------------------------------- /src/read_A2.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern word tns; 20 | 21 | /***********************************************************************/ 22 | /* Cmd:0F Fnc:A2 > Read 3 address fields in SLC500 */ 23 | /* Read Protected Typed Logical */ 24 | /***********************************************************************/ 25 | int read_A2(TThree_Address_Fields address, void *value, byte size) 26 | { 27 | TCmd cmd; 28 | TMsg sendMsg,rcvMsg; 29 | 30 | int error=ERROR_READ_A2; 31 | 32 | bzero(value,size); 33 | bzero(&sendMsg,sizeof(sendMsg)); 34 | bzero(&rcvMsg,sizeof(rcvMsg)); 35 | bzero(&cmd,sizeof(cmd)); 36 | sendMsg.dst = DEST; 37 | sendMsg.src = SOURCE; 38 | sendMsg.cmd = 0x0F; 39 | sendMsg.sts = 0x00; 40 | sendMsg.tns = ++tns; 41 | cmd.fnc = 0xA2; 42 | cmd.size = address.size; 43 | cmd.fileNumber = address.fileNumber; 44 | cmd.fileType = address.fileType; 45 | cmd.eleNumber = address.eleNumber; 46 | cmd.s_eleNumber = address.s_eleNumber; 47 | memcpy(&sendMsg.data,&cmd,sizeof(cmd)); 48 | sendMsg.size = sizeof(cmd); 49 | if ((error=send_DF1(sendMsg))!=0) 50 | return error; 51 | if ((error=rcv_DF1(&rcvMsg))!=0) 52 | return error; 53 | if (rcvMsg.tns!=sendMsg.tns) 54 | return ERROR_TNS_MISMATCH; 55 | if (rcvMsg.sts!=0) 56 | return rcvMsg.sts; 57 | memcpy(value,rcvMsg.data,address.size); 58 | return SUCCES; 59 | } 60 | -------------------------------------------------------------------------------- /src/write_AA.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern word tns; 20 | 21 | /***********************************************************************/ 22 | /* Cmd:0F Fnc:AA > write 3 address fields in SLC500 */ 23 | /* Write Protected Typed Logical */ 24 | /***********************************************************************/ 25 | int write_AA(TThree_Address_Fields address, void *value, byte size) 26 | { 27 | TCmd cmd; 28 | TMsg sendMsg,rcvMsg; 29 | int error=ERROR_WRITE_AA; 30 | 31 | bzero(&sendMsg,sizeof(sendMsg)); 32 | bzero(&rcvMsg,sizeof(rcvMsg)); 33 | bzero(&cmd,sizeof(cmd)); 34 | sendMsg.dst = DEST; 35 | sendMsg.src = SOURCE; 36 | sendMsg.cmd = 0x0F; 37 | sendMsg.sts = 0x00; 38 | sendMsg.tns = ++tns; 39 | cmd.fnc = 0xAA; 40 | cmd.size = address.size; 41 | cmd.fileNumber = address.fileNumber; 42 | cmd.fileType = address.fileType; 43 | cmd.eleNumber = address.eleNumber; 44 | cmd.s_eleNumber = address.s_eleNumber; 45 | memcpy(&sendMsg.data,&cmd,sizeof(cmd)); 46 | sendMsg.size = sizeof(cmd); 47 | memcpy(&sendMsg.data[sendMsg.size],value,cmd.size); 48 | sendMsg.size += cmd.size; 49 | if ((error=send_DF1(sendMsg))!=0) 50 | return error; 51 | if ((error=rcv_DF1(&rcvMsg))!=0) 52 | return error; 53 | if (rcvMsg.tns!=sendMsg.tns) 54 | return ERROR_TNS_MISMATCH; 55 | if (rcvMsg.sts!=0) 56 | return rcvMsg.sts; 57 | return SUCCES; 58 | } 59 | -------------------------------------------------------------------------------- /src/read_socket.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | int read_socket(char *rcvmsg, char *response) 19 | { 20 | int error=ERROR; 21 | int fnct; 22 | int plctype=SLC; 23 | word value; 24 | int varbool; 25 | float varfloat; 26 | char Address[20]; 27 | char writevalue[20]; 28 | 29 | fnct=select_fnct(rcvmsg,Address,writevalue); 30 | switch (fnct) 31 | { 32 | case 1 : 33 | if ((error=read_integer(plctype,Address,&value))==SUCCES) { 34 | sprintf(response,"%d",value); 35 | //strcat(response,"\n"); 36 | } 37 | break; 38 | case 2 : 39 | if ((error=read_boolean(plctype,Address,&varbool))==SUCCES) { 40 | sprintf(response,"%i",varbool); 41 | //strcat(response,"\n"); 42 | } 43 | break; 44 | case 3 : 45 | if ((error=read_float(plctype,Address,&varfloat))==SUCCES) { 46 | sprintf(response,"%f",varfloat); 47 | //strcat(response,"\n"); 48 | } 49 | break; 50 | case 11 : 51 | value = atoi(writevalue); 52 | if ((error=write_integer(plctype,Address,&value))==SUCCES) { 53 | sprintf(response,"%d",value); 54 | //strcat(response,"\n"); 55 | } 56 | break; 57 | case 12 : 58 | varbool = atoi(writevalue); 59 | if ((error=write_boolean(plctype,Address,&varbool))==SUCCES) { 60 | sprintf(response,"%d",varbool); 61 | //strcat(response,"\n"); 62 | } 63 | break; 64 | case 13 : 65 | varfloat = atof(writevalue); 66 | if ((error=write_float(plctype,Address,&varfloat))==SUCCES) { 67 | sprintf(response,"%f",varfloat); 68 | //strcat(response,"\n"); 69 | } 70 | break; 71 | default: 72 | error=fnct; 73 | break; 74 | } 75 | return error; 76 | } 77 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ============================================================================ 2 | = df1 1.0.0 23/01/2003 = 3 | ============================================================================ 4 | 5 | 6 | ====================================== 7 | Author 8 | ====================================== 9 | Author: Stephane LEICHT 10 | e-mail: stephane.leicht@gmail.com 11 | 12 | 13 | ====================================== 14 | Requirements 15 | ====================================== 16 | a SLC500 or micrologix connected on the serial port. 17 | 18 | 19 | ====================================== 20 | Install 21 | ====================================== 22 | 23 | Compilation: make 24 | 25 | install : copy df1 in /usr/bin 26 | copy df1d in /etc/init.d 27 | 28 | ====================================== 29 | Features 30 | ====================================== 31 | This program is a daemon to communicate with ethernet TCPIP from programmable logic 32 | controller SLC500 and MicroLogix ALLEN-BRADLEY connected on the serial port (df1). 33 | 34 | ====================================== 35 | Licence 36 | ====================================== 37 | This program is free software: you can redistribute it and/or modify 38 | it under the terms of the GNU General Public License as published by 39 | the Free Software Foundation, either version 3 of the License, or 40 | (at your option) any later version. 41 | 42 | This program is distributed in the hope that it will be useful, 43 | but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | GNU General Public License for more details. 46 | 47 | You should have received a copy of the GNU General Public License 48 | along with this program. If not, see . 49 | 50 | ====================================== 51 | Getting started 52 | ====================================== 53 | start df1 daemon with the script df1d > /etc/init.d/df1d start 54 | 55 | open a telnet session > telnet localhost 17560 56 | 57 | read integer value in SLC500 > N7:1 58 | write integer value in SLC500 > N7:1=456 59 | T4:0.PRE=15 60 | 61 | read float value in SLC500 > F8:5 62 | write float value in SLC500 > F8:2=-3.14 63 | F8:1=5E-4 64 | F8:0=7.001 65 | 66 | read boolean value in SLC500 > B3:0/5 67 | T4:0.dn 68 | write boolean value in SLC500 > B3:0/5=1 69 | B3:0/4=0 70 | 71 | you can view logs in /var/log/syslog. 72 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern word tns; 20 | int file; 21 | int Terminated=FALSE; 22 | 23 | void Termine (int sig); 24 | 25 | //******************** MAIN ************ 26 | int main (void) 27 | { 28 | openlog("DF1",LOG_NDELAY,LOG_DAEMON); 29 | setlogmask(~LOG_MASK(LOG_DEBUG)); // no debug informations 30 | 31 | signal(SIGTERM,Termine); 32 | signal(SIGINT,Termine); 33 | signal(SIGQUIT,Termine); 34 | signal(SIGSEGV,Termine); 35 | 36 | if ((file=Df1_open_device ("/dev/ttyS0", 9600,0,8,1)) == -1) 37 | { 38 | MyLog("OpenCom Failed\n"); 39 | return (-1); 40 | } 41 | 42 | #ifndef DEBUG 43 | switch (fork()) 44 | { 45 | case -1: 46 | syslog(LOG_NOTICE,"Erreur a la creation du Daemon"); 47 | //closelog; 48 | exit(1); 49 | case 0: 50 | setsid(); 51 | chdir("/"); 52 | umask(0); 53 | close(0); 54 | close(1); 55 | close(2); 56 | syslog(LOG_NOTICE,"Daemon OK"); 57 | if (file == -1) 58 | { 59 | syslog(LOG_NOTICE,"OpenCom Failed\n"); 60 | //closelog; 61 | exit(2); 62 | } 63 | else 64 | { 65 | #endif 66 | server(); 67 | close (file); 68 | exit(0); 69 | #ifndef DEBUG 70 | } 71 | default : exit(0); 72 | } 73 | #endif 74 | } 75 | //********************************************* 76 | void Termine (int sig) 77 | { 78 | switch (sig) 79 | { 80 | case SIGTERM: syslog(LOG_NOTICE,"receive SIGTERM\n"); 81 | Terminated=TRUE; 82 | break; 83 | case SIGINT: syslog(LOG_NOTICE,"receive SIGINT\n"); 84 | Terminated=TRUE; 85 | break; 86 | case SIGQUIT: syslog(LOG_NOTICE,"receive SIGQUIT\n"); 87 | Terminated=TRUE; 88 | break; 89 | case SIGSEGV: syslog(LOG_NOTICE,"receive SIGSEGV, program ERROR\n"); 90 | Terminated=TRUE; 91 | break; 92 | default: syslog(LOG_NOTICE,"receive signal: %d\n",sig); 93 | Terminated=TRUE; 94 | break; 95 | } 96 | } 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/select_fnct.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | //return 1:read_integer 2:read_boolean 3:read_float 19 | //return 11:write_integer 12:write_boolean 13:write_float 20 | int select_fnct(char *strquery, char *address, char *value) 21 | { 22 | int result=ERROR; 23 | int x; 24 | char filetype[]= "OISBTCRNF"; 25 | int writequery=FALSE; 26 | char *varaddress; 27 | char *varvalue; 28 | const char delimiters[] = "=\n\r"; 29 | 30 | //begin by alphaFile ? 31 | if (strchr(filetype,toupper(strquery[0]))==NULL) { 32 | return ERROR_BAD_QUERY; 33 | } 34 | //find ':' in query ? 35 | if (strchr(strquery,58)==NULL) { 36 | return ERROR_BAD_QUERY; 37 | } 38 | 39 | //find '=' in query ? if yes > write value in SLC 40 | if (strchr(strquery,61)!=NULL) { 41 | writequery=TRUE; 42 | } 43 | 44 | varaddress = strsep (&strquery, delimiters); 45 | //upper ALL 46 | for (x=0;x. 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern int file; 20 | 21 | /***********************************************************************/ 22 | word bytes2word(byte lowb, byte highb) 23 | { 24 | word w; 25 | char c[2];//={lowb,highb}; 26 | c[0]=lowb; 27 | c[1]=highb; 28 | memcpy(&w,c,sizeof(w)); 29 | return w; 30 | } 31 | 32 | /***********************************************************************/ 33 | int add_word2buffer(TBuffer * buffer, word value) /* return new buffer size */ 34 | { 35 | memcpy(buffer->data+buffer->size, &value,sizeof(value)); 36 | buffer->size += sizeof(value); 37 | return buffer->size; 38 | } 39 | 40 | 41 | /***********************************************************************/ 42 | int add_byte2buffer(TBuffer * buffer, byte value) /* return new buffer size */ 43 | { 44 | memcpy(buffer->data+buffer->size, &value,sizeof(value)); 45 | buffer->size += sizeof(value); 46 | return buffer->size; 47 | } 48 | 49 | /***********************************************************************/ 50 | int add_data2buffer(TBuffer * buffer, void * data, byte size) /* return new buffer size */ 51 | { 52 | memcpy(buffer->data+buffer->size, data,size); 53 | buffer->size += size; 54 | return buffer->size; 55 | } 56 | 57 | /***********************************************************************/ 58 | /* Add DLE if DLE exist in buffer **************************************/ 59 | int add_data2bufferWithDLE(TBuffer * buffer, TMsg msg) /* return new buffer size */ 60 | { 61 | byte i; 62 | byte databyte[262]; 63 | memcpy(&databyte, &msg,sizeof(msg)); 64 | for (i=0;isize; 71 | } 72 | 73 | /***********************************************************************/ 74 | int is_timeout(int start_time) 75 | { 76 | if ((time ((time_t *) 0)-start_time)>TIME_OUT) 77 | return ERROR_TIMEOUT; 78 | else 79 | return SUCCES; 80 | } 81 | 82 | /***********************************************************************/ 83 | void print_symbol(byte c) 84 | { 85 | switch (c) 86 | { 87 | case STX : 88 | puts("STX\n"); 89 | break; 90 | case ETX : 91 | puts("ETX\n"); 92 | break; 93 | case ENQ : 94 | puts("ENQ\n"); 95 | break; 96 | case ACK : 97 | puts("ACK\n"); 98 | break; 99 | case NAK : 100 | puts("NAK\n"); 101 | break; 102 | case DLE : 103 | puts("DLE\n"); 104 | break; 105 | default : printf("??:%02X\n",c); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/server.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern int Terminated; 20 | 21 | //********************************************************* 22 | int server(void) 23 | { 24 | struct sockaddr_in monadr, sonadr; 25 | int fd, opt=1, taille; 26 | int serv_sock, client_sock; 27 | int nb_lu; 28 | int nfds; 29 | fd_set rfds, afds; 30 | int error; 31 | 32 | char message[20]=""; 33 | char response[20]=""; 34 | 35 | MyLog("Create server ...\n"); 36 | serv_sock = socket(PF_INET, SOCK_STREAM, 0); 37 | setsockopt(serv_sock, SOL_SOCKET, SO_REUSEADDR,(char *) &opt, sizeof(opt)); 38 | 39 | /* init socket serveur */ 40 | bzero( (char *)&monadr, sizeof monadr); 41 | monadr.sin_family = AF_INET; 42 | monadr.sin_port = htons(PORT); 43 | monadr.sin_addr.s_addr = INADDR_ANY; 44 | 45 | if( bind(serv_sock, (struct sockaddr *)&monadr, sizeof(monadr)) == -1 ) { 46 | return(1); 47 | } 48 | 49 | if( listen(serv_sock, MAXCONN) == -1 ) { 50 | return(1); 51 | } 52 | 53 | /* init sockets list*/ 54 | nfds = getdtablesize(); 55 | FD_ZERO(&afds); 56 | FD_SET(serv_sock, &afds); 57 | 58 | /* gestion des clients */ 59 | while(!Terminated) 60 | { 61 | memcpy(&rfds, &afds, sizeof(rfds)); 62 | if( select(nfds, &rfds, 0, 0, 0) == -1 ) 63 | {/* signaux non bloquants */ 64 | if( errno == EINTR ) continue; 65 | return(1); 66 | } 67 | if( FD_ISSET(serv_sock, &rfds) ) /* New connection ?*/ 68 | { 69 | taille = sizeof sonadr; 70 | if( (client_sock = accept(serv_sock, (struct sockaddr *)&sonadr,(socklen_t *)&taille)) == -1 ) 71 | { 72 | return(1); 73 | } 74 | //syslog(LOG_NOTICE,"client connection from %s \n", inet_ntoa(sonadr.sin_addr)); 75 | fflush(stdout); 76 | FD_SET(client_sock, &afds); 77 | fcntl(client_sock, F_SETFL, O_NONBLOCK | fcntl(client_sock, F_GETFL, 0)); 78 | } 79 | /* Tester si les sockets clientes ont boug�s */ 80 | for( fd=0; fd 0 ) { 88 | message[nb_lu]='\0'; 89 | if ((error=read_socket(message,response))!=SUCCES) { 90 | sprintf(response,"error :%d\n",error); 91 | } 92 | strcat(response,"\n"); 93 | write(fd, response, strlen(response)); 94 | } else { 95 | close(fd); 96 | FD_CLR(fd, &afds); 97 | } 98 | } 99 | } 100 | } 101 | return(0); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /src/calc_address.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | int calc_address(char *straddress,TThree_Address_Fields *address) 20 | { 21 | int error=ERROR_CALC_ADDRESS; 22 | int x,l; 23 | bzero(address,sizeof(*address)); 24 | address->size=0; 25 | address->fileNumber=0; 26 | address->fileType=0; 27 | address->eleNumber=0; 28 | address->s_eleNumber=0; 29 | for (x=0;xfileType = 0x8b; 35 | address->fileNumber = 0; 36 | address->size = 2; 37 | break; 38 | case 'I': 39 | address->fileType = 0x8c; 40 | address->fileNumber = 1; 41 | address->size = 2; 42 | break; 43 | case 'S': 44 | x++; 45 | address->fileType = 0x84; 46 | address->fileNumber = atoi(&straddress[x]); 47 | address->size = 2; 48 | break; 49 | case 'B': 50 | x++; 51 | address->fileType = 0x85; 52 | address->fileNumber = atoi(&straddress[x]); 53 | address->size = 2; 54 | break; 55 | case 'T': 56 | x++; 57 | address->fileType = 0x86; 58 | address->fileNumber = atoi(&straddress[x]); 59 | address->size = 2; 60 | break; 61 | case 'C': 62 | x++; 63 | address->fileType = 0x87; 64 | address->fileNumber = atoi(&straddress[x]); 65 | address->size = 2; 66 | break; 67 | case 'R': 68 | x++; 69 | address->fileType = 0x88; 70 | address->fileNumber = atoi(&straddress[x]); 71 | address->size = 2; 72 | break; 73 | case 'N': 74 | x++; 75 | address->fileType = 0x89; 76 | address->fileNumber = atoi(&straddress[x]); 77 | address->size=2; 78 | break; 79 | case 'F': 80 | x++; 81 | address->fileType = 0x8a; 82 | address->fileNumber = atoi(&straddress[x]); 83 | address->size = 4; 84 | break; 85 | case ':': 86 | address->eleNumber = atoi(&straddress[++x]); 87 | break; 88 | case '.': 89 | case '/': 90 | x++; 91 | if (isdigit(straddress[x])) { 92 | address->s_eleNumber = atoi(&straddress[x]); 93 | } 94 | l=strlen(straddress) - x; 95 | if (strncasecmp (&straddress[x],"acc",l) == 0 ) 96 | address->s_eleNumber = 2; 97 | if (strncasecmp (&straddress[x],"pre",l) == 0 ) 98 | address->s_eleNumber = 1; 99 | if (strncasecmp (&straddress[x],"len",l) == 0 ) 100 | address->s_eleNumber = 1; 101 | if (strncasecmp (&straddress[x],"pos",l) == 0 ) 102 | address->s_eleNumber = 2; 103 | if (strncasecmp (&straddress[x],"en",l) == 0 ) 104 | address->s_eleNumber = 13; 105 | if (strncasecmp (&straddress[x],"tt",l) == 0 ) 106 | address->s_eleNumber = 14; 107 | if (strncasecmp (&straddress[x],"dn",l) == 0 ) 108 | address->s_eleNumber = 15; 109 | x = strlen(straddress)-1; 110 | } 111 | } 112 | error=SUCCES; 113 | return error; 114 | } 115 | -------------------------------------------------------------------------------- /src/df1.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | // Version 1.0.0 :23 Jan 2003 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | struct termios saved_tty_parameters; /* old serial port setting (restored on close) */ 38 | struct termios Df1_tio; /* new serial port setting */ 39 | 40 | #define DLE 0x10 41 | #define STX 0x02 42 | #define ETX 0X03 43 | #define ENQ 0x05 44 | #define ACK 0x06 45 | #define NAK 0x15 46 | 47 | #define DEST 0x01 48 | #define SOURCE 0x00 49 | 50 | // plctype 51 | #define SLC 1 52 | #define PLC 2 53 | 54 | #define FALSE 0 55 | #define TRUE 1 56 | 57 | #define TIME_OUT 1 //in seconds 58 | 59 | //Error 60 | #define SUCCES 0 61 | #define ERROR -1 62 | #define ERROR_NAK -2 63 | #define ERROR_SENDDF1 -3 64 | #define ERROR_RCVDF1 -4 65 | #define ERROR_TIMEOUT -5 66 | #define ERROR_BAD_QUERY -6 67 | #define ERROR_TNS_MISMATCH -9 68 | #define ERROR_READ_A2 -10 69 | #define ERROR_READ_INTEGER -20 70 | #define ERROR_CALC_ADDRESS -30 71 | #define ERROR_WRITE_AA -40 72 | #define ERROR_WRITE -41 73 | #define ERROR_WRITE_AB -42 74 | 75 | //Flag 76 | #define DATA_FLAG 1 77 | #define CONTROL_FLAG 2 78 | 79 | //Server 80 | #define BUFSIZE 20 81 | #define PORT 17560 82 | #define MAXCONN 5 83 | #define MAX_CLIENTS 10 84 | 85 | /* Define Debug for a console appli, else Daemon*/ 86 | //#define DEBUG 87 | #ifdef DEBUG 88 | #define MyLog printf 89 | #else 90 | #define MyLog(m) syslog(LOG_NOTICE,m) 91 | #endif 92 | //********************************************************************** 93 | 94 | typedef unsigned char byte; /* create byte type */ 95 | typedef unsigned short word; /* create word type */ 96 | 97 | /* TMsg structure */ 98 | typedef struct { 99 | byte dst; 100 | byte src; 101 | byte cmd; 102 | byte sts; 103 | word tns; 104 | byte data[255]; 105 | byte size; 106 | } TMsg; 107 | 108 | /* TBuffer structure */ 109 | typedef struct { 110 | byte data[512]; 111 | byte size; 112 | } TBuffer; 113 | 114 | /* TThree_Address_Fields structure*/ 115 | typedef struct { 116 | byte size; 117 | byte fileNumber; 118 | byte fileType; 119 | byte eleNumber; 120 | byte s_eleNumber; 121 | } TThree_Address_Fields; 122 | 123 | /* TCmd */ 124 | typedef struct { 125 | byte fnc; 126 | byte size; 127 | byte fileNumber; 128 | byte fileType; 129 | byte eleNumber; 130 | byte s_eleNumber; 131 | } TCmd; 132 | 133 | /* TCmd4 */ 134 | typedef struct { 135 | byte fnc; 136 | byte size; 137 | byte fileNumber; 138 | byte fileType; 139 | byte eleNumber; 140 | byte s_eleNumber; 141 | word maskbyte; 142 | word value; 143 | } TCmd4; 144 | 145 | /*************/ 146 | /* functions */ 147 | /*************/ 148 | // serial.c 149 | int Df1_open_device(char [], int , int , int ,int ); /* open device and configure it */ 150 | void Df1_close_device(int); /* close device and restore old parmeters */ 151 | 152 | // common.c 153 | word bytes2word(byte lowb, byte highb); 154 | int add_word2buffer(TBuffer * buffer, word value); 155 | int add_byte2buffer(TBuffer *buffer, byte value); 156 | int add_data2buffer(TBuffer * buffer, void * data, byte size); 157 | int add_data2bufferWithDLE(TBuffer * buffer, TMsg msg); 158 | void print_symbol(byte c); 159 | int is_timeout(int start_time); 160 | 161 | // df1.c 162 | word calc_crc (word crc, word buffer) ; 163 | word compute_crc (TBuffer * buffer); 164 | int send_DF1(TMsg Df1Data); 165 | int rcv_DF1(TMsg * Df1Data); 166 | int get_symbol(byte * b); 167 | void sendResponse(byte response); 168 | int read_byte(byte * b); 169 | 170 | //read 171 | int read_A2(TThree_Address_Fields address, void *value, byte size); 172 | int read_integer(int plctype, char *straddress,word *value); 173 | int read_float(int plctype, char *straddress, float *value); 174 | int read_boolean(int plctype, char *straddress, int *value); 175 | //write 176 | int write_AA(TThree_Address_Fields address, void *value, byte size); 177 | int write_integer(int plctype, char *straddress, word *value); 178 | int write_float(int plctype, char *straddress, float *value); 179 | int write_AB(TThree_Address_Fields address, word value, word mask); 180 | int write_boolean(int plctype, char *straddress, int *value); 181 | 182 | int calc_address(char *straddress,TThree_Address_Fields *address); 183 | int select_fnct(char *strquery, char *address, char *value); 184 | int read_socket(char *rcvmsg, char *response); 185 | int server(void); 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /src/serial.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /* This file is inspired by source code of LibModbus 0.0.1 18 | Author: Laurent LOPES 19 | e-mail: pes@free.fr 20 | homepage: pes.free.fr */ 21 | 22 | #include "df1.h" 23 | 24 | word tns; 25 | 26 | /***********************************************************************************/ 27 | void Df1_close_device(int Df1_device) 28 | { 29 | if (tcsetattr (Df1_device,TCSANOW,&saved_tty_parameters) < 0) 30 | MyLog("Can't restore terminal parameters "); 31 | close(Df1_device); 32 | } 33 | 34 | /************************************************************************************ 35 | Df1_open_device : open the device 36 | ************************************************************************************* 37 | input : 38 | ------- 39 | Df1_port : string with the device to open (/dev/ttyS0, /dev/ttyS1,...) 40 | Df1_speed : speed (baudrate) 41 | Df1_parity : 0=don't use parity, 1=use parity EVEN, -1 use parity ODD 42 | Df1_bit_l : number of data bits : 7 or 8 USE EVERY TIME 8 DATA BITS 43 | Df1_bit_s : number of stop bits : 1 or 2 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | answer : 46 | --------- 47 | device descriptor 48 | ************************************************************************************/ 49 | int Df1_open_device(char Df1_port[20], int Df1_speed, int Df1_parity, int Df1_bit_l, int Df1_bit_s) 50 | { 51 | int fd; 52 | 53 | /* open port */ 54 | fd = open(Df1_port,O_RDWR | O_NOCTTY | O_NDELAY) ;//| O_NONBLOCK 55 | if(fd<0) 56 | { 57 | MyLog("Open device failure\n") ; 58 | exit(-1) ; 59 | } 60 | 61 | /* save olds settings port */ 62 | if (tcgetattr (fd,&saved_tty_parameters) < 0) 63 | { 64 | MyLog("Can't get terminal parameters "); 65 | return -1 ; 66 | } 67 | 68 | /* settings port */ 69 | bzero(&Df1_tio,sizeof(&Df1_tio)); 70 | 71 | switch (Df1_speed) 72 | { 73 | case 0: 74 | Df1_tio.c_cflag = B0; 75 | break; 76 | case 50: 77 | Df1_tio.c_cflag = B50; 78 | break; 79 | case 75: 80 | Df1_tio.c_cflag = B75; 81 | break; 82 | case 110: 83 | Df1_tio.c_cflag = B110; 84 | break; 85 | case 134: 86 | Df1_tio.c_cflag = B134; 87 | break; 88 | case 150: 89 | Df1_tio.c_cflag = B150; 90 | break; 91 | case 200: 92 | Df1_tio.c_cflag = B200; 93 | break; 94 | case 300: 95 | Df1_tio.c_cflag = B300; 96 | break; 97 | case 600: 98 | Df1_tio.c_cflag = B600; 99 | break; 100 | case 1200: 101 | Df1_tio.c_cflag = B1200; 102 | break; 103 | case 1800: 104 | Df1_tio.c_cflag = B1800; 105 | break; 106 | case 2400: 107 | Df1_tio.c_cflag = B2400; 108 | break; 109 | case 4800: 110 | Df1_tio.c_cflag = B4800; 111 | break; 112 | case 9600: 113 | Df1_tio.c_cflag = B9600; 114 | break; 115 | case 19200: 116 | Df1_tio.c_cflag = B19200; 117 | break; 118 | case 38400: 119 | Df1_tio.c_cflag = B38400; 120 | break; 121 | case 57600: 122 | Df1_tio.c_cflag = B57600; 123 | break; 124 | case 115200: 125 | Df1_tio.c_cflag = B115200; 126 | break; 127 | case 230400: 128 | Df1_tio.c_cflag = B230400; 129 | break; 130 | default: 131 | Df1_tio.c_cflag = B9600; 132 | } 133 | switch (Df1_bit_l) 134 | { 135 | case 7: 136 | Df1_tio.c_cflag = Df1_tio.c_cflag | CS7; 137 | break; 138 | case 8: 139 | default: 140 | Df1_tio.c_cflag = Df1_tio.c_cflag | CS8; 141 | break; 142 | } 143 | switch (Df1_parity) 144 | { 145 | case 1: 146 | Df1_tio.c_cflag = Df1_tio.c_cflag | PARENB; 147 | break; 148 | case -1: 149 | Df1_tio.c_cflag = Df1_tio.c_cflag | PARENB | PARODD; 150 | break; 151 | case 0: 152 | default: 153 | Df1_tio.c_iflag = IGNPAR; 154 | break; 155 | } 156 | 157 | if (Df1_bit_s==2) 158 | Df1_tio.c_cflag = Df1_tio.c_cflag | CSTOPB; 159 | 160 | Df1_tio.c_cflag = Df1_tio.c_cflag | CLOCAL | CREAD ; 161 | Df1_tio.c_oflag = 0; 162 | Df1_tio.c_lflag = 0; /*1=ICANON;*/ 163 | Df1_tio.c_cc[VMIN]=0; 164 | Df1_tio.c_cc[VTIME]=0; 165 | 166 | /* clean port */ 167 | tcflush(fd, TCIFLUSH); 168 | 169 | fcntl(fd, F_SETFL, FASYNC); 170 | /* activate the settings port */ 171 | if (tcsetattr(fd,TCSANOW,&Df1_tio) <0) 172 | { 173 | MyLog("Can't set terminal parameters "); 174 | return -1 ; 175 | } 176 | 177 | /* clean I & O device */ 178 | tcflush(fd,TCIOFLUSH); 179 | /* init tns for DF1 */ 180 | tns = (word) time((time_t *)0); 181 | 182 | return fd ; 183 | } 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /src/df1.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Stephane LEICHT (stephane.leicht@gmail.com) 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "df1.h" 18 | 19 | extern int file; 20 | extern word tns; 21 | struct timeval tv; 22 | 23 | /***********************************************************************/ 24 | word calc_crc (word crc, word buffer) 25 | { 26 | word temp1, y; 27 | //MyLog ("buffer[x] = %04X\n",buffer); 28 | temp1 = crc ^ buffer; 29 | crc = (crc & 0xff00) | (temp1 & 0xff); 30 | for (y = 0; y < 8; y++) 31 | { 32 | if (crc & 1) 33 | { 34 | crc = crc >> 1; 35 | crc ^= 0xa001; 36 | } 37 | else 38 | crc = crc >> 1; 39 | } 40 | return crc; 41 | } 42 | 43 | /***********************************************************************/ 44 | word compute_crc (TBuffer * buffer) 45 | { 46 | byte x; 47 | word crc = 0; 48 | for (x=0;xsize;x++) { 49 | crc = calc_crc (crc, buffer->data[x]); 50 | } 51 | crc = calc_crc (crc,ETX); 52 | //MyLog("CRC : %04X\n",crc); 53 | return (crc); 54 | } 55 | 56 | 57 | /***********************************************************************/ 58 | int send_DF1(TMsg Df1Data) 59 | { 60 | int error=ERROR_SENDDF1; 61 | int flag; 62 | byte c; 63 | TBuffer crcBuffer,dataSend,dataRcv; 64 | time_t time_start; 65 | int nbr_NAK=0; 66 | int nbr_ENQ=0; 67 | //int x; 68 | 69 | //build message to send 70 | bzero(&crcBuffer,sizeof(crcBuffer)); 71 | bzero(&dataSend,sizeof(dataSend)); 72 | bzero(&dataRcv,sizeof(dataRcv)); 73 | add_byte2buffer(&dataSend,DLE); 74 | add_byte2buffer(&dataSend,STX); 75 | add_data2bufferWithDLE(&dataSend,Df1Data); 76 | add_byte2buffer(&dataSend,DLE); 77 | add_byte2buffer(&dataSend,ETX); 78 | add_data2buffer(&crcBuffer,&Df1Data,Df1Data.size+6); 79 | add_word2buffer(&dataSend, compute_crc(&crcBuffer)); 80 | //for (x=0;x3) 97 | return ERROR_TIMEOUT; 98 | else 99 | { 100 | sendResponse(ENQ); 101 | time_start=time((time_t *) 0); 102 | tv.tv_sec = TIME_OUT; 103 | tv.tv_usec = 0; 104 | } 105 | } 106 | flag=get_symbol(&c); 107 | } while ((flag!=CONTROL_FLAG) & ((c!=ACK) | (c!=NAK))); 108 | if (c==ACK) 109 | return SUCCES; 110 | if (c==NAK) 111 | { 112 | error=ERROR_NAK; 113 | ++nbr_NAK; 114 | } 115 | } while (nbr_NAK<=3); 116 | return error; 117 | } 118 | 119 | /***********************************************************************/ 120 | int rcv_DF1(TMsg * Df1Data) 121 | { 122 | byte c,crcb1,crcb2; 123 | byte last_response; 124 | word crc; 125 | int error = ERROR_RCVDF1; 126 | TBuffer dataRcv; 127 | int flag; 128 | int crcOK=FALSE; 129 | 130 | do 131 | { 132 | bzero(&dataRcv,sizeof(dataRcv)); 133 | last_response = NAK; 134 | do 135 | { 136 | flag=get_symbol(&c); 137 | if (flag<0) 138 | return flag; 139 | } while (flag!=CONTROL_FLAG); 140 | switch (c) 141 | { 142 | case ENQ : 143 | sendResponse(last_response); 144 | break; 145 | case STX : 146 | while ((flag=get_symbol(&c))!=CONTROL_FLAG) 147 | { 148 | add_byte2buffer(&dataRcv,c); 149 | } 150 | if (c==ETX) 151 | { 152 | if (read_byte(&crcb1)!=SUCCES) 153 | return error; 154 | if (read_byte(&crcb2)!=SUCCES) 155 | return error; 156 | 157 | crc=bytes2word(crcb1,crcb2); 158 | if (crc==compute_crc(&dataRcv)) 159 | { 160 | sendResponse(ACK); 161 | crcOK=TRUE; 162 | error=SUCCES; 163 | } 164 | else 165 | { 166 | sendResponse(NAK); 167 | crcOK=FALSE; 168 | } 169 | } 170 | else 171 | { 172 | sendResponse(NAK); 173 | } 174 | break; 175 | default : sendResponse(NAK); 176 | } 177 | } while (crcOK != TRUE); 178 | memcpy(Df1Data,dataRcv.data,dataRcv.size); 179 | return error; 180 | } 181 | 182 | /***********************************************************************/ 183 | int get_symbol(byte * b) 184 | { 185 | byte c1,c2; 186 | int error; 187 | if ((error=read_byte(&c1))!=SUCCES) 188 | return error; 189 | if (c1==DLE) 190 | { 191 | if ((error=read_byte(&c2))!=SUCCES) 192 | return error; 193 | *b = c2; 194 | switch (c2) 195 | { 196 | case DLE: return DATA_FLAG; 197 | case ETX: return CONTROL_FLAG; 198 | case STX: return CONTROL_FLAG; 199 | case ENQ: return CONTROL_FLAG; 200 | case ACK: return CONTROL_FLAG; 201 | case NAK: return CONTROL_FLAG; 202 | } 203 | } 204 | *b = c1; 205 | return DATA_FLAG; 206 | } 207 | 208 | /***********************************************************************/ 209 | void sendResponse(byte response) // used to send NAK or ACK 210 | { 211 | word w; 212 | byte dle=DLE; 213 | w=bytes2word(dle,response); 214 | write (file, &w, 2); 215 | } 216 | 217 | /***********************************************************************/ 218 | int read_byte(byte * b) 219 | { 220 | fd_set rfds; 221 | int retval; 222 | FD_ZERO(&rfds); 223 | FD_SET(file, &rfds); 224 | retval=select(file+1, &rfds, NULL, NULL, &tv); 225 | switch (retval) 226 | { 227 | case 0: return ERROR_TIMEOUT; 228 | case -1: return retval; 229 | default : 230 | if (FD_ISSET(file,&rfds)) 231 | { 232 | if (read(file, b, 1)!=1) 233 | return ERROR; 234 | else 235 | { 236 | //MyLog("Read :%02X\n",*b); 237 | return SUCCES; 238 | } 239 | } 240 | else 241 | return ERROR; 242 | } 243 | 244 | } 245 | 246 | 247 | 248 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 2.8 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | .PHONY : default_target 7 | 8 | #============================================================================= 9 | # Special targets provided by cmake. 10 | 11 | # Disable implicit rules so canoncical targets will work. 12 | .SUFFIXES: 13 | 14 | # Remove some rules from gmake that .SUFFIXES does not remove. 15 | SUFFIXES = 16 | 17 | .SUFFIXES: .hpux_make_needs_suffix_list 18 | 19 | # Suppress display of executed commands. 20 | $(VERBOSE).SILENT: 21 | 22 | # A target that is always out of date. 23 | cmake_force: 24 | .PHONY : cmake_force 25 | 26 | #============================================================================= 27 | # Set environment variables for the build. 28 | 29 | # The shell in which to execute make rules. 30 | SHELL = /bin/sh 31 | 32 | # The CMake executable. 33 | CMAKE_COMMAND = /usr/bin/cmake 34 | 35 | # The command to remove a file. 36 | RM = /usr/bin/cmake -E remove -f 37 | 38 | # The top-level source directory on which CMake was run. 39 | CMAKE_SOURCE_DIR = /home/leicht/Documents/Stephane/prog/fox/df1 40 | 41 | # The top-level build directory on which CMake was run. 42 | CMAKE_BINARY_DIR = /home/leicht/Documents/Stephane/prog/fox/df1 43 | 44 | #============================================================================= 45 | # Targets provided globally by CMake. 46 | 47 | # Special rule for the target edit_cache 48 | edit_cache: 49 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." 50 | /usr/bin/cmake -i . 51 | .PHONY : edit_cache 52 | 53 | # Special rule for the target edit_cache 54 | edit_cache/fast: edit_cache 55 | .PHONY : edit_cache/fast 56 | 57 | # Special rule for the target rebuild_cache 58 | rebuild_cache: 59 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." 60 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 61 | .PHONY : rebuild_cache 62 | 63 | # Special rule for the target rebuild_cache 64 | rebuild_cache/fast: rebuild_cache 65 | .PHONY : rebuild_cache/fast 66 | 67 | # The main all target 68 | all: cmake_check_build_system 69 | $(CMAKE_COMMAND) -E cmake_progress_start /home/leicht/Documents/Stephane/prog/fox/df1/CMakeFiles /home/leicht/Documents/Stephane/prog/fox/df1/CMakeFiles/progress.marks 70 | $(MAKE) -f CMakeFiles/Makefile2 all 71 | $(CMAKE_COMMAND) -E cmake_progress_start /home/leicht/Documents/Stephane/prog/fox/df1/CMakeFiles 0 72 | .PHONY : all 73 | 74 | # The main clean target 75 | clean: 76 | $(MAKE) -f CMakeFiles/Makefile2 clean 77 | .PHONY : clean 78 | 79 | # The main clean target 80 | clean/fast: clean 81 | .PHONY : clean/fast 82 | 83 | # Prepare targets for installation. 84 | preinstall: all 85 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 86 | .PHONY : preinstall 87 | 88 | # Prepare targets for installation. 89 | preinstall/fast: 90 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 91 | .PHONY : preinstall/fast 92 | 93 | # clear depends 94 | depend: 95 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 96 | .PHONY : depend 97 | 98 | #============================================================================= 99 | # Target rules for targets named df1 100 | 101 | # Build rule for target. 102 | df1: cmake_check_build_system 103 | $(MAKE) -f CMakeFiles/Makefile2 df1 104 | .PHONY : df1 105 | 106 | # fast build rule for target. 107 | df1/fast: 108 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/build 109 | .PHONY : df1/fast 110 | 111 | src/calc_address.o: src/calc_address.c.o 112 | .PHONY : src/calc_address.o 113 | 114 | # target to build an object file 115 | src/calc_address.c.o: 116 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/calc_address.c.o 117 | .PHONY : src/calc_address.c.o 118 | 119 | src/calc_address.i: src/calc_address.c.i 120 | .PHONY : src/calc_address.i 121 | 122 | # target to preprocess a source file 123 | src/calc_address.c.i: 124 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/calc_address.c.i 125 | .PHONY : src/calc_address.c.i 126 | 127 | src/calc_address.s: src/calc_address.c.s 128 | .PHONY : src/calc_address.s 129 | 130 | # target to generate assembly for a file 131 | src/calc_address.c.s: 132 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/calc_address.c.s 133 | .PHONY : src/calc_address.c.s 134 | 135 | src/common.o: src/common.c.o 136 | .PHONY : src/common.o 137 | 138 | # target to build an object file 139 | src/common.c.o: 140 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/common.c.o 141 | .PHONY : src/common.c.o 142 | 143 | src/common.i: src/common.c.i 144 | .PHONY : src/common.i 145 | 146 | # target to preprocess a source file 147 | src/common.c.i: 148 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/common.c.i 149 | .PHONY : src/common.c.i 150 | 151 | src/common.s: src/common.c.s 152 | .PHONY : src/common.s 153 | 154 | # target to generate assembly for a file 155 | src/common.c.s: 156 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/common.c.s 157 | .PHONY : src/common.c.s 158 | 159 | src/df1.o: src/df1.c.o 160 | .PHONY : src/df1.o 161 | 162 | # target to build an object file 163 | src/df1.c.o: 164 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/df1.c.o 165 | .PHONY : src/df1.c.o 166 | 167 | src/df1.i: src/df1.c.i 168 | .PHONY : src/df1.i 169 | 170 | # target to preprocess a source file 171 | src/df1.c.i: 172 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/df1.c.i 173 | .PHONY : src/df1.c.i 174 | 175 | src/df1.s: src/df1.c.s 176 | .PHONY : src/df1.s 177 | 178 | # target to generate assembly for a file 179 | src/df1.c.s: 180 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/df1.c.s 181 | .PHONY : src/df1.c.s 182 | 183 | src/main.o: src/main.c.o 184 | .PHONY : src/main.o 185 | 186 | # target to build an object file 187 | src/main.c.o: 188 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/main.c.o 189 | .PHONY : src/main.c.o 190 | 191 | src/main.i: src/main.c.i 192 | .PHONY : src/main.i 193 | 194 | # target to preprocess a source file 195 | src/main.c.i: 196 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/main.c.i 197 | .PHONY : src/main.c.i 198 | 199 | src/main.s: src/main.c.s 200 | .PHONY : src/main.s 201 | 202 | # target to generate assembly for a file 203 | src/main.c.s: 204 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/main.c.s 205 | .PHONY : src/main.c.s 206 | 207 | src/read_A2.o: src/read_A2.c.o 208 | .PHONY : src/read_A2.o 209 | 210 | # target to build an object file 211 | src/read_A2.c.o: 212 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_A2.c.o 213 | .PHONY : src/read_A2.c.o 214 | 215 | src/read_A2.i: src/read_A2.c.i 216 | .PHONY : src/read_A2.i 217 | 218 | # target to preprocess a source file 219 | src/read_A2.c.i: 220 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_A2.c.i 221 | .PHONY : src/read_A2.c.i 222 | 223 | src/read_A2.s: src/read_A2.c.s 224 | .PHONY : src/read_A2.s 225 | 226 | # target to generate assembly for a file 227 | src/read_A2.c.s: 228 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_A2.c.s 229 | .PHONY : src/read_A2.c.s 230 | 231 | src/read_boolean.o: src/read_boolean.c.o 232 | .PHONY : src/read_boolean.o 233 | 234 | # target to build an object file 235 | src/read_boolean.c.o: 236 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_boolean.c.o 237 | .PHONY : src/read_boolean.c.o 238 | 239 | src/read_boolean.i: src/read_boolean.c.i 240 | .PHONY : src/read_boolean.i 241 | 242 | # target to preprocess a source file 243 | src/read_boolean.c.i: 244 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_boolean.c.i 245 | .PHONY : src/read_boolean.c.i 246 | 247 | src/read_boolean.s: src/read_boolean.c.s 248 | .PHONY : src/read_boolean.s 249 | 250 | # target to generate assembly for a file 251 | src/read_boolean.c.s: 252 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_boolean.c.s 253 | .PHONY : src/read_boolean.c.s 254 | 255 | src/read_float.o: src/read_float.c.o 256 | .PHONY : src/read_float.o 257 | 258 | # target to build an object file 259 | src/read_float.c.o: 260 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_float.c.o 261 | .PHONY : src/read_float.c.o 262 | 263 | src/read_float.i: src/read_float.c.i 264 | .PHONY : src/read_float.i 265 | 266 | # target to preprocess a source file 267 | src/read_float.c.i: 268 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_float.c.i 269 | .PHONY : src/read_float.c.i 270 | 271 | src/read_float.s: src/read_float.c.s 272 | .PHONY : src/read_float.s 273 | 274 | # target to generate assembly for a file 275 | src/read_float.c.s: 276 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_float.c.s 277 | .PHONY : src/read_float.c.s 278 | 279 | src/read_integer.o: src/read_integer.c.o 280 | .PHONY : src/read_integer.o 281 | 282 | # target to build an object file 283 | src/read_integer.c.o: 284 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_integer.c.o 285 | .PHONY : src/read_integer.c.o 286 | 287 | src/read_integer.i: src/read_integer.c.i 288 | .PHONY : src/read_integer.i 289 | 290 | # target to preprocess a source file 291 | src/read_integer.c.i: 292 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_integer.c.i 293 | .PHONY : src/read_integer.c.i 294 | 295 | src/read_integer.s: src/read_integer.c.s 296 | .PHONY : src/read_integer.s 297 | 298 | # target to generate assembly for a file 299 | src/read_integer.c.s: 300 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_integer.c.s 301 | .PHONY : src/read_integer.c.s 302 | 303 | src/read_socket.o: src/read_socket.c.o 304 | .PHONY : src/read_socket.o 305 | 306 | # target to build an object file 307 | src/read_socket.c.o: 308 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_socket.c.o 309 | .PHONY : src/read_socket.c.o 310 | 311 | src/read_socket.i: src/read_socket.c.i 312 | .PHONY : src/read_socket.i 313 | 314 | # target to preprocess a source file 315 | src/read_socket.c.i: 316 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_socket.c.i 317 | .PHONY : src/read_socket.c.i 318 | 319 | src/read_socket.s: src/read_socket.c.s 320 | .PHONY : src/read_socket.s 321 | 322 | # target to generate assembly for a file 323 | src/read_socket.c.s: 324 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/read_socket.c.s 325 | .PHONY : src/read_socket.c.s 326 | 327 | src/select_fnct.o: src/select_fnct.c.o 328 | .PHONY : src/select_fnct.o 329 | 330 | # target to build an object file 331 | src/select_fnct.c.o: 332 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/select_fnct.c.o 333 | .PHONY : src/select_fnct.c.o 334 | 335 | src/select_fnct.i: src/select_fnct.c.i 336 | .PHONY : src/select_fnct.i 337 | 338 | # target to preprocess a source file 339 | src/select_fnct.c.i: 340 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/select_fnct.c.i 341 | .PHONY : src/select_fnct.c.i 342 | 343 | src/select_fnct.s: src/select_fnct.c.s 344 | .PHONY : src/select_fnct.s 345 | 346 | # target to generate assembly for a file 347 | src/select_fnct.c.s: 348 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/select_fnct.c.s 349 | .PHONY : src/select_fnct.c.s 350 | 351 | src/serial.o: src/serial.c.o 352 | .PHONY : src/serial.o 353 | 354 | # target to build an object file 355 | src/serial.c.o: 356 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/serial.c.o 357 | .PHONY : src/serial.c.o 358 | 359 | src/serial.i: src/serial.c.i 360 | .PHONY : src/serial.i 361 | 362 | # target to preprocess a source file 363 | src/serial.c.i: 364 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/serial.c.i 365 | .PHONY : src/serial.c.i 366 | 367 | src/serial.s: src/serial.c.s 368 | .PHONY : src/serial.s 369 | 370 | # target to generate assembly for a file 371 | src/serial.c.s: 372 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/serial.c.s 373 | .PHONY : src/serial.c.s 374 | 375 | src/server.o: src/server.c.o 376 | .PHONY : src/server.o 377 | 378 | # target to build an object file 379 | src/server.c.o: 380 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/server.c.o 381 | .PHONY : src/server.c.o 382 | 383 | src/server.i: src/server.c.i 384 | .PHONY : src/server.i 385 | 386 | # target to preprocess a source file 387 | src/server.c.i: 388 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/server.c.i 389 | .PHONY : src/server.c.i 390 | 391 | src/server.s: src/server.c.s 392 | .PHONY : src/server.s 393 | 394 | # target to generate assembly for a file 395 | src/server.c.s: 396 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/server.c.s 397 | .PHONY : src/server.c.s 398 | 399 | src/write_AA.o: src/write_AA.c.o 400 | .PHONY : src/write_AA.o 401 | 402 | # target to build an object file 403 | src/write_AA.c.o: 404 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AA.c.o 405 | .PHONY : src/write_AA.c.o 406 | 407 | src/write_AA.i: src/write_AA.c.i 408 | .PHONY : src/write_AA.i 409 | 410 | # target to preprocess a source file 411 | src/write_AA.c.i: 412 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AA.c.i 413 | .PHONY : src/write_AA.c.i 414 | 415 | src/write_AA.s: src/write_AA.c.s 416 | .PHONY : src/write_AA.s 417 | 418 | # target to generate assembly for a file 419 | src/write_AA.c.s: 420 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AA.c.s 421 | .PHONY : src/write_AA.c.s 422 | 423 | src/write_AB.o: src/write_AB.c.o 424 | .PHONY : src/write_AB.o 425 | 426 | # target to build an object file 427 | src/write_AB.c.o: 428 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AB.c.o 429 | .PHONY : src/write_AB.c.o 430 | 431 | src/write_AB.i: src/write_AB.c.i 432 | .PHONY : src/write_AB.i 433 | 434 | # target to preprocess a source file 435 | src/write_AB.c.i: 436 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AB.c.i 437 | .PHONY : src/write_AB.c.i 438 | 439 | src/write_AB.s: src/write_AB.c.s 440 | .PHONY : src/write_AB.s 441 | 442 | # target to generate assembly for a file 443 | src/write_AB.c.s: 444 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_AB.c.s 445 | .PHONY : src/write_AB.c.s 446 | 447 | src/write_boolean.o: src/write_boolean.c.o 448 | .PHONY : src/write_boolean.o 449 | 450 | # target to build an object file 451 | src/write_boolean.c.o: 452 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_boolean.c.o 453 | .PHONY : src/write_boolean.c.o 454 | 455 | src/write_boolean.i: src/write_boolean.c.i 456 | .PHONY : src/write_boolean.i 457 | 458 | # target to preprocess a source file 459 | src/write_boolean.c.i: 460 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_boolean.c.i 461 | .PHONY : src/write_boolean.c.i 462 | 463 | src/write_boolean.s: src/write_boolean.c.s 464 | .PHONY : src/write_boolean.s 465 | 466 | # target to generate assembly for a file 467 | src/write_boolean.c.s: 468 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_boolean.c.s 469 | .PHONY : src/write_boolean.c.s 470 | 471 | src/write_float.o: src/write_float.c.o 472 | .PHONY : src/write_float.o 473 | 474 | # target to build an object file 475 | src/write_float.c.o: 476 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_float.c.o 477 | .PHONY : src/write_float.c.o 478 | 479 | src/write_float.i: src/write_float.c.i 480 | .PHONY : src/write_float.i 481 | 482 | # target to preprocess a source file 483 | src/write_float.c.i: 484 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_float.c.i 485 | .PHONY : src/write_float.c.i 486 | 487 | src/write_float.s: src/write_float.c.s 488 | .PHONY : src/write_float.s 489 | 490 | # target to generate assembly for a file 491 | src/write_float.c.s: 492 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_float.c.s 493 | .PHONY : src/write_float.c.s 494 | 495 | src/write_integer.o: src/write_integer.c.o 496 | .PHONY : src/write_integer.o 497 | 498 | # target to build an object file 499 | src/write_integer.c.o: 500 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_integer.c.o 501 | .PHONY : src/write_integer.c.o 502 | 503 | src/write_integer.i: src/write_integer.c.i 504 | .PHONY : src/write_integer.i 505 | 506 | # target to preprocess a source file 507 | src/write_integer.c.i: 508 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_integer.c.i 509 | .PHONY : src/write_integer.c.i 510 | 511 | src/write_integer.s: src/write_integer.c.s 512 | .PHONY : src/write_integer.s 513 | 514 | # target to generate assembly for a file 515 | src/write_integer.c.s: 516 | $(MAKE) -f CMakeFiles/df1.dir/build.make CMakeFiles/df1.dir/src/write_integer.c.s 517 | .PHONY : src/write_integer.c.s 518 | 519 | # Help Target 520 | help: 521 | @echo "The following are some of the valid targets for this Makefile:" 522 | @echo "... all (the default if no target is provided)" 523 | @echo "... clean" 524 | @echo "... depend" 525 | @echo "... df1" 526 | @echo "... edit_cache" 527 | @echo "... rebuild_cache" 528 | @echo "... src/calc_address.o" 529 | @echo "... src/calc_address.i" 530 | @echo "... src/calc_address.s" 531 | @echo "... src/common.o" 532 | @echo "... src/common.i" 533 | @echo "... src/common.s" 534 | @echo "... src/df1.o" 535 | @echo "... src/df1.i" 536 | @echo "... src/df1.s" 537 | @echo "... src/main.o" 538 | @echo "... src/main.i" 539 | @echo "... src/main.s" 540 | @echo "... src/read_A2.o" 541 | @echo "... src/read_A2.i" 542 | @echo "... src/read_A2.s" 543 | @echo "... src/read_boolean.o" 544 | @echo "... src/read_boolean.i" 545 | @echo "... src/read_boolean.s" 546 | @echo "... src/read_float.o" 547 | @echo "... src/read_float.i" 548 | @echo "... src/read_float.s" 549 | @echo "... src/read_integer.o" 550 | @echo "... src/read_integer.i" 551 | @echo "... src/read_integer.s" 552 | @echo "... src/read_socket.o" 553 | @echo "... src/read_socket.i" 554 | @echo "... src/read_socket.s" 555 | @echo "... src/select_fnct.o" 556 | @echo "... src/select_fnct.i" 557 | @echo "... src/select_fnct.s" 558 | @echo "... src/serial.o" 559 | @echo "... src/serial.i" 560 | @echo "... src/serial.s" 561 | @echo "... src/server.o" 562 | @echo "... src/server.i" 563 | @echo "... src/server.s" 564 | @echo "... src/write_AA.o" 565 | @echo "... src/write_AA.i" 566 | @echo "... src/write_AA.s" 567 | @echo "... src/write_AB.o" 568 | @echo "... src/write_AB.i" 569 | @echo "... src/write_AB.s" 570 | @echo "... src/write_boolean.o" 571 | @echo "... src/write_boolean.i" 572 | @echo "... src/write_boolean.s" 573 | @echo "... src/write_float.o" 574 | @echo "... src/write_float.i" 575 | @echo "... src/write_float.s" 576 | @echo "... src/write_integer.o" 577 | @echo "... src/write_integer.i" 578 | @echo "... src/write_integer.s" 579 | .PHONY : help 580 | 581 | 582 | 583 | #============================================================================= 584 | # Special targets to cleanup operation of make. 585 | 586 | # Special rule to run CMake to check the build system integrity. 587 | # No rule that depends on this can have commands that come from listfiles 588 | # because they might be regenerated. 589 | cmake_check_build_system: 590 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 591 | .PHONY : cmake_check_build_system 592 | 593 | --------------------------------------------------------------------------------