├── README.md ├── comm.c ├── comm.h ├── direct_tests.c ├── hostlink.c ├── hostlink.h ├── models.h ├── propies.c ├── propies.h └── status_plc.c /README.md: -------------------------------------------------------------------------------- 1 | # hostlink 2 | Simple C library for communicate with Omrom PLCs Hostlink protocol 3 | -------------------------------------------------------------------------------- /comm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomeucapo/hostlink/2906d75328cd3979c7eed347c6057ebbf86d42b8/comm.c -------------------------------------------------------------------------------- /comm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomeucapo/hostlink/2906d75328cd3979c7eed347c6057ebbf86d42b8/comm.h -------------------------------------------------------------------------------- /direct_tests.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomeucapo/hostlink/2906d75328cd3979c7eed347c6057ebbf86d42b8/direct_tests.c -------------------------------------------------------------------------------- /hostlink.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomeucapo/hostlink/2906d75328cd3979c7eed347c6057ebbf86d42b8/hostlink.c -------------------------------------------------------------------------------- /hostlink.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomeucapo/hostlink/2906d75328cd3979c7eed347c6057ebbf86d42b8/hostlink.h -------------------------------------------------------------------------------- /models.h: -------------------------------------------------------------------------------- 1 | /* 2 | Distins models de PLC's que soporten 3 | protocol Host Link. 4 | */ 5 | 6 | char *models[13][2]={{"01","C250"}, 7 | {"02","C500"}, 8 | {"03","C120"}, 9 | {"0E","C2000"}, 10 | {"10","C1000H"}, 11 | {"11","C2000H/CQM1/CPM1"}, 12 | {"12","C20H/C28H/C40H/C200H/C200HS"}, 13 | {"20","CV500"}, 14 | {"21","CV1000"}, 15 | {"22","CV2000"}, 16 | {"40","CVM1-CPU01-E"}, 17 | {"41","CVM1-CPU11-E"}, 18 | {"42","CVM1-CPU21-E"}}; 19 | -------------------------------------------------------------------------------- /propies.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | char *duplica_cad(char *s) 5 | { 6 | char *p; 7 | 8 | p=(char *) malloc(strlen(s)+1); 9 | 10 | if(p!=NULL) 11 | strcpy(p,s); 12 | 13 | return p; 14 | } 15 | -------------------------------------------------------------------------------- /propies.h: -------------------------------------------------------------------------------- 1 | 2 | char *duplica_cad(char *); 3 | -------------------------------------------------------------------------------- /status_plc.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "comm.h" 7 | #include "hostlink.h" 8 | #include "models.h" 9 | 10 | int main(void) 11 | { 12 | p_port COM5; 13 | p_plc cpm1; 14 | int resposta; 15 | 16 | COM5 = defineix_port("/dev/ttyS10",B9600, CS7 | CSTOPB | PARENB); 17 | cpm1 = designa_plc(0x11,0); 18 | 19 | obre_port(COM5); 20 | 21 | printf("Port obert..\n"); 22 | 23 | envia_comanda(COM5,"@00MM40*\r"); 24 | rebre_comanda(COM5); 25 | 26 | printf("Rebuda la resposta: %10s\n",in_buffer(COM5)); 27 | printf("Comanda interpretada: %d\n",que_es(in_buffer(COM5))); 28 | printf("Comprovant comanda: %d\n",comprova_comanda(cpm1,in_buffer(COM5))); 29 | 30 | 31 | tanca_port(COM5); 32 | 33 | 34 | 35 | // free(cpm1); 36 | free(COM5); 37 | 38 | } 39 | --------------------------------------------------------------------------------