Marisol Mánica / Mbed 2 deprecated fotoprueba

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
SolManB
Date:
Mon Nov 09 20:12:58 2015 +0000
Commit message:
Para comprimir imagen

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 09 20:12:58 2015 +0000
@@ -0,0 +1,77 @@
+#include "mbed.h"
+#include<stdio.h>
+#include<string.h> 
+#include<iostream>
+#include<fstream>
+#include<errno.h>
+
+DigitalOut myled(LED1);
+LocalFileSystem local("local"); 
+
+using namespace std;
+int m=0;
+
+void send_image(){
+
+   FILE *picture;
+   FILE *respaldo=NULL;
+   int size, read_size, stat, packet_index;
+   char send_buffer[10240], read_buffer[256];
+   packet_index = 1;
+
+   picture = fopen("/local/PICT003.JPG", "r");
+   printf("Getting Picture Size\n");   
+    
+    //PAra el respaldoç
+     respaldo = fopen("/local/respaldo.txt", "w");  
+   if(picture == NULL) {
+        printf("Error Opening Image File"); } 
+
+   fseek(picture, 0, SEEK_END);
+   size = ftell(picture);
+   fseek(picture, 0, SEEK_SET);
+   printf("Total Picture size: %i\n",size);
+
+   //Send Picture Size
+   printf("Sending Picture Size\n");
+   fprintf(respaldo, "1. %d,\n\r",size);
+
+   //Send Picture as Byte Array
+   printf("Sending Picture as Byte Array\n");
+
+   int t=2;
+   while(!feof(picture)) {
+   //while(packet_index = 1){
+      //Read from the file into our send buffer
+      read_size = fread(send_buffer, 1, sizeof(send_buffer)-1, picture);
+
+      //Send data through our socket 
+
+       fprintf(respaldo,"%d. ",t);  //checar
+      while(m<read_size)
+      {
+          fprintf(respaldo,"%02hhx   ",send_buffer[m]);
+          m++;
+        }
+        fprintf(respaldo,",%d,\n",read_size);
+        m=0;
+
+      printf("Packet Number: %i\n",packet_index);
+      printf("Packet Size Sent: %i\n",read_size);     
+      printf(" \n");
+      printf(" \n");
+
+
+      packet_index++;  
+        t++;
+      //Zero out our send buffer
+      
+     }
+     fclose(respaldo);
+      fclose(picture);
+}
+
+int main()
+{
+    send_image();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 09 20:12:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file