EthTCPclient_05

Files at this revision

API Documentation at this revision

Comitter:
bosko001
Date:
Mon Feb 24 13:55:09 2020 +0000
Parent:
4:0aec01df33d2
Commit message:
EthTCPclient_5

Changed in this revision

PGSdisplay.c Show diff for this revision Revisions of this file
PGSdisplay.cpp Show annotated file Show diff for this revision Revisions of this file
PGSdisplay.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0aec01df33d2 -r ecaf089d1c8a PGSdisplay.c
--- a/PGSdisplay.c	Sat Feb 22 17:17:54 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-
-//#include "mbed.h"
-//#include "platform/mbed_thread.h"
-
-
-#include <string.h>
-
-#include "PGSdisplay.h"
-#include "DigitalOut.h"
-
-extern DigitalOut tast;
-//RawSerial rs485(PTC17,PTC16);
-extern RawSerial rs485;
-
-
-void ev(int)
-{
-    tast=0;
-}
-
-
-
-unsigned char buf_tel[100] = {0x71,0x00,0x0D,0x71,0x43,0x1,0x1B,0x4A,0x01,0x01,  /*0x1b,0x45,0x1,*/  0x1B,0x43,1,0x33,0xD5,0x16};
-#define NO_BEFORE_DATA 13
-#define NO_WITH_DATA (NO_BEFORE_DATA + strlen(s))
-
-void putOnDisp( char *s, char boja)
-{
-    int ubb = NO_BEFORE_DATA+strlen(s)+1+1-4-2; // ubb = ukupan broj bajtova
-    buf_tel[NO_BEFORE_DATA-1]=boja;
-    memcpy(buf_tel+NO_BEFORE_DATA, s, strlen(s)+2);
-
-    char suma=0;
-    for(int i = 4; i < NO_WITH_DATA; i++) {
-        suma +=buf_tel[i];
-    }
-
-    buf_tel[NO_WITH_DATA] = suma;
-    buf_tel[NO_WITH_DATA+1] = 22;
-    buf_tel[1]=ubb>>8;
-    buf_tel[2]=ubb;
-
-
-    tast=1;
-    rs485.write(buf_tel, NO_WITH_DATA+2+2,ev);
-}
-
-void putOnDispNo(int broj, char boja)
-{
-    char s[10];
-    sprintf( s, "%d", broj);
-    putOnDisp( s, boja);
-}
-
-
-void slanjefun()
-{
-
-    int j=0;
-
-
-    while (true) {
-//       printf("disp thred %d\n\r",j);
-        if(j >10 && j<15 ) putOnDisp("des",1);
-        else putOnDispNo(j,1);
-        j++;
-        thread_sleep_for(1000);
-    }
-}
-
-
-char * extract_string( char delimiter, char *ulazni_str, int n_str )
-{
-    int br_str=0;
-    char *ret_str=ulazni_str;
-    char* ptr = ulazni_str;
-
-    while(*ptr) {
-        if(*ptr == delimiter) {
-            *ptr = 0;
-            if( br_str == n_str )   return ret_str;
-            else {
-                br_str++;
-                ret_str = ptr + 1;
-            }
-        }
-        ptr++;
-    }
-    if( br_str == n_str )   return ret_str;
-    return NULL;
-}
-
diff -r 0aec01df33d2 -r ecaf089d1c8a PGSdisplay.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PGSdisplay.cpp	Mon Feb 24 13:55:09 2020 +0000
@@ -0,0 +1,99 @@
+
+//#include "mbed.h"
+//#include "platform/mbed_thread.h"
+
+#include "mbed.h"
+
+#include "PGSdisplay.h"
+
+#define DISP_ADR   40
+
+DigitalOut tast(PTB19,0);
+////RawSerial rs485(PTC17,PTC16);
+RawSerial rs485(PTD3,PTD2);
+
+
+void ev(int)
+{
+    tast=0;
+}
+
+void init_disp( void)
+{
+   rs485.format(8,RawSerial::Even,1);   
+
+    putOnDisp("elcom", 3);
+
+
+}
+
+unsigned char buf_tel[100] = {0x71,0x00,0x0D,0x71,0x43,DISP_ADR,0x1B,0x4A,0x01,0x01,  /*0x1b,0x45,0x1,*/  0x1B,0x43,1,0x33,0xD5,0x16};
+#define NO_BEFORE_DATA 13
+#define NO_WITH_DATA (NO_BEFORE_DATA + strlen(s))
+
+void putOnDisp( char *s, char boja)
+{
+    int ubb = NO_BEFORE_DATA+strlen(s)+1+1-4-2; // ubb = ukupan broj bajtova
+    buf_tel[NO_BEFORE_DATA-1]=boja;
+    memcpy(buf_tel+NO_BEFORE_DATA, s, strlen(s)+2);
+
+    char suma=0;
+    for(int i = 4; i < NO_WITH_DATA; i++) {
+        suma +=buf_tel[i];
+    }
+
+    buf_tel[NO_WITH_DATA] = suma;
+    buf_tel[NO_WITH_DATA+1] = 22;
+    buf_tel[1]=ubb>>8;
+    buf_tel[2]=ubb;
+
+
+    tast=1;
+    rs485.write(buf_tel, NO_WITH_DATA+2+2,ev);
+}
+
+void putOnDispNo(int broj, char boja)
+{
+    char s[10];
+    sprintf( s, "%d", broj);
+    putOnDisp( s, boja);
+}
+
+
+void slanjefun()
+{
+
+    int j=0;
+
+
+    while (true) {
+//       printf("disp thred %d\n\r",j);
+        if(j >10 && j<15 ) putOnDisp((char*)"des",1);
+        else putOnDispNo(j,1);
+        j++;
+        thread_sleep_for(1000);
+    }
+}
+
+
+char * extract_string( char delimiter, char *ulazni_str, int n_str )
+{
+    int br_str=0;
+    char *ret_str=ulazni_str;
+    char* ptr = ulazni_str;
+
+    while(*ptr) {
+        if(*ptr == delimiter) {
+            *ptr = 0;
+            if( br_str == n_str )   return ret_str;
+            else {
+                br_str++;
+                ret_str = ptr + 1;
+            }
+        }
+        ptr++;
+    }
+    if( br_str == n_str )   return ret_str;
+    return NULL;
+}
+
diff -r 0aec01df33d2 -r ecaf089d1c8a PGSdisplay.h
--- a/PGSdisplay.h	Sat Feb 22 17:17:54 2020 +0000
+++ b/PGSdisplay.h	Mon Feb 24 13:55:09 2020 +0000
@@ -2,7 +2,7 @@
 #ifndef PGSDISPLAY_H
 #define PGSDISPLAY_H
  
-
+void init_disp( void);
 void putOnDisp( char *s, char boja);
 void putOnDispNo(int broj, char boja);
 char * extract_string( char delimiter, char *ulazni_str, int n_str );
diff -r 0aec01df33d2 -r ecaf089d1c8a main.cpp
--- a/main.cpp	Sat Feb 22 17:17:54 2020 +0000
+++ b/main.cpp	Mon Feb 24 13:55:09 2020 +0000
@@ -39,9 +39,9 @@
 void tcpThread_fun( EthernetInterface *e);
 void requestMessage( EthernetInterface *e);
 //
-DigitalOut tast(PTB19,0);
-////RawSerial rs485(PTC17,PTC16);
-RawSerial rs485(PTD3,PTD2);
+//DigitalOut tast(PTB19,0);
+//////RawSerial rs485(PTC17,PTC16);
+//RawSerial rs485(PTD3,PTD2);
 
 struct s_rm {
     EthernetInterface *e;
@@ -85,13 +85,8 @@
 {
 
 
-
-    rs485.format(8, mbed::RawSerial::Even, 1);
+    init_disp( );
 
-    Thread t;
-//   t.start( slanjefun );
-
-    putOnDisp("elcom", 3);
 
     if( (err = eth.set_network(IP_ADDR,NET_MASK,GATW_ADDR))!= NSAPI_ERROR_OK )  {
         printf(" greska setovanja mreze %d \n\r", err);
@@ -207,83 +202,3 @@
 //};
 
 
-
-//
-//
-//void ev(int)
-//{
-//    tast=0;
-//}
-//
-//
-//
-//unsigned char buf_tel[100] = {0x71,0x00,0x0D,0x71,0x43,0x1,0x1B,0x4A,0x01,0x01,  /*0x1b,0x45,0x1,*/  0x1B,0x43,1,0x33,0xD5,0x16};
-//#define NO_BEFORE_DATA 13
-//#define NO_WITH_DATA (NO_BEFORE_DATA + strlen(s))
-//
-//void putOnDisp( char *s, char boja)
-//{
-//    int ubb = NO_BEFORE_DATA+strlen(s)+1+1-4-2; // ubb = ukupan broj bajtova
-//    buf_tel[NO_BEFORE_DATA-1]=boja;
-//    memcpy(buf_tel+NO_BEFORE_DATA, s, strlen(s)+2);
-//
-//    char suma=0;
-//    for(int i = 4; i < NO_WITH_DATA; i++) {
-//        suma +=buf_tel[i];
-//    }
-//
-//    buf_tel[NO_WITH_DATA] = suma;
-//    buf_tel[NO_WITH_DATA+1] = 22;
-//    buf_tel[1]=ubb>>8;
-//    buf_tel[2]=ubb;
-//
-//
-//    tast=1;
-//    rs485.write(buf_tel, NO_WITH_DATA+2+2,ev);
-//}
-//
-//void putOnDispNo(int broj, char boja)
-//{
-//    char s[10];
-//    sprintf( s, "%d", broj);
-//    putOnDisp( s, boja);
-//}
-//
-//
-//void slanjefun()
-//{
-//
-//    int j=0;
-//
-//
-//    while (true) {
-////       printf("disp thred %d\n\r",j);
-//        if(j >10 && j<15 ) putOnDisp("des",1);
-//        else putOnDispNo(j,1);
-//        j++;
-//        thread_sleep_for(1000);
-//    }
-//}
-//
-//
-//char * extract_string( char delimiter, char *ulazni_str, int n_str )
-//{
-//    int br_str=0;
-//    char *ret_str=ulazni_str;
-//    char* ptr = ulazni_str;
-//
-//    while(*ptr) {
-//        if(*ptr == delimiter) {
-//            *ptr = 0;
-//            if( br_str == n_str )   return ret_str;
-//            else {
-//                br_str++;
-//                ret_str = ptr + 1;
-//            }
-//        }
-//        ptr++;
-//    }
-//    if( br_str == n_str )   return ret_str;
-//    return NULL;
-//}
-//