π
<-

[LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+CE !

Assembleur, Axe, C/C++, ICE...

Re: [LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+C

Unread postby tom-garnier » Today, 12:26

Bonjour à tous
Me revoilà ;)
J'ai essayé de refaire fonctionner le programme avec la nouvelle version publiée récemment, et cela ne fonctionne pas, la calculatrice crash toujours
Avec des étapes longues de débug, j'ai réussi à isoler le morceau qui réalise le crash, mais la calculatrice ne reçoit aucune données malgré ça.

Voici ce que j'ai modifié :
http.c
Code: Select all
web_status_t http_request(const char *request_type, const char* url, http_data_t **data, bool keep_http_header,
                          char *params, bool is_https) {
   /* Ignoring http:// or https:// */
   const char *https_str = "https://";
   const char *http_str = "http://";
   if(is_https && strncmp(url, https_str, strlen(https_str)) == 0) {
      url += 8;
   } else if(!is_https && strncmp(url, http_str, strlen(http_str)) == 0) {
      url += 7;
   }

   printf("HTTP %s %s\n", request_type, url);
   while(!os_GetCSC()) {}

   bool is_ip = true;
   size_t websitelen = 0;
   while(url[websitelen] != '/' && url[websitelen] != 0x00) {
      is_ip &= url[websitelen] < 'A';
      websitelen++;
   }

   printf("Websitelen %d\n", websitelen);
   while(!os_GetCSC()) {}

   bool has_path = url[websitelen] == '/'; /* '/' or 0x00 ? */

   /* Formatting website name */
   char websitename[websitelen + 1];
   memcpy(websitename, url, websitelen);
   websitename[websitelen] = 0x00;

   printf("Websitename %s\n", websitename);
   while(!os_GetCSC()) {}

   uint32_t ip;
   if(!is_ip) {
      ip = web_SendDNSRequest(websitename);
   } else {
      ip = ip_ascii_to_hex(websitename);
   }

   printf("IP %x\n", (unsigned int)ip);
   while(!os_GetCSC()) {}

   if(ip == 0xffffffff) {
      return WEB_DNS_ERROR;
   }

   /* Configuring request information */
   http_exchange_t *http_exch = _malloc(sizeof(http_exchange_t), "httpx");
   if(http_exch == NULL) {
      return WEB_NOT_ENOUGH_MEM;
   }

   printf("Allocating %d bytes\n", sizeof(http_exchange_t));
   while(!os_GetCSC()) {}

   memset(http_exch, 0, sizeof(http_exchange_t));
   http_exch->buffer_size = 536;  /* Starting size, will be resized later */
   http_exch->data = data;
   http_exch->buffer = _malloc(http_exch->buffer_size, "httpb");
   if(http_exch->buffer == NULL) {
      _free(http_exch);
      return WEB_NOT_ENOUGH_MEM;
   }

   printf("Allocating %d bytes\n", http_exch->buffer_size);
   while(!os_GetCSC()) {}


   http_exch->keep_http_header = keep_http_header;
    http_exch->timeout = false;
   http_exch->dirty = false;
   void *exchange;  /* Opaque type depending on the underlying protocol used to send data (TCP or TLS) */
   if(is_https) {
      exchange = web_TLSConnect(ip, HTTPS_PORT, websitename, fetch_http_msg, http_exch);
   } else {
      exchange = web_TCPConnect(ip, HTTP_PORT, fetch_http_msg, http_exch);
   }


   printf("Exchange %p\n", exchange);
   while(!os_GetCSC()) {}


    if(exchange == NULL) {
      _free(http_exch->buffer);
      _free(http_exch);
      return WEB_ERROR_FAILED;
   }


   web_status_t ret_val = delay_event(TIMEOUT_HTTP * 1000, boolean_scheduler, boolean_destructor, &http_exch->timeout);



   printf("Ret_val %d\n", ret_val);
   while(!os_GetCSC()) {}



   if(ret_val != WEB_SUCCESS) {
      if(is_https) {
         web_TLSClose(exchange, true);
      } else {
         web_TCPClose(exchange, true);
      }
      _free(http_exch->buffer);
      _free(http_exch);
      return ret_val;
   }

   /* Building HTTP request */
   uint24_t length = (strlen(BASIC_HTTP_REQUEST) - (4 * 2) /* 4 '%s' options */ + strlen(request_type) +
                 !has_path /* if no path, add 1 for '/' char */ + strlen(url) + strlen(params));
   
   char request[length + 1];
   snprintf(request, length + 1, BASIC_HTTP_REQUEST, request_type, has_path ? &url[websitelen] : "/", websitename, params);


   printf("Request %s\n", request);
   while(!os_GetCSC()) {}



   /* Sending HTTP request */
   if(is_https) {
      ret_val = web_DeliverTLSData(exchange, request, length);
   } else {
      ret_val = web_DeliverTCPSegment(exchange, request, length);
   }


   printf("Delivering data %d\n", ret_val);
   while(!os_GetCSC()) {}


   /*if(ret_val != WEB_SUCCESS) {
      http_exch->dirty = true;
      http_exch->status = ret_val;
   }*/

   /* Waiting for the end of the request */
   /*while(!http_exch->dirty) {
      web_WaitForEvents();
      if(http_exch->timeout) {
         http_exch->dirty = true;
         http_exch->status = WEB_TIMEOUT;
         dbg_err("HTTP Timeout");
      }
   }*/


   printf("Request finished\n");
   while(!os_GetCSC()) {}



   remove_event(&http_exch->timeout);

   printf("Event removed\n");
   while(!os_GetCSC()) {}

   const web_status_t ret_status = http_exch->status;
   const bool is_succeeded = ret_status >= 100;  /* 100 = minimum HTTP status code, below this is the lib status codes */
   if(is_https) {
      web_TLSClose(exchange, !is_succeeded);
   } else {
      web_TCPClose(exchange, !is_succeeded);
   }

   printf("Closing connection\n");
   while(!os_GetCSC()) {}

   _free(http_exch->buffer);
   _free(http_exch);

   printf("Freeing buffer\n");
   while(!os_GetCSC()) {}

   /* To send the FIN and potential ACK segments (in case the user quits) */
   force_send_queue();

   printf("Forcing send queue\n");
   while(!os_GetCSC()) {}


   return ret_status;
}



Et le retour console que j'ai eu:
HTTP GET http://www.perdu.com
Websitelen 13 bytes
Websitename http://www.perdu.com
IP 51568
Allocating 31 bytes
Allocating 536 bytes
Exchange 0xd053e4
Ret_val 0
Request GET / HTTP/1.1
HOST: http://www.perdu.com
Delivering data 0
Request finished
Event removed
Closing connection
Freeing buffer
Forcing send queue
Something after requestErr 0: couldn't retrieve foreign data




Je continuerais à effectuer des recherches, mais si certains ont des idées





EDIT:
Après analyse WireShark, la calculatrice fetch l'ip du domaine à l'aide des DNS google (ceux de mon téléphone), et obtient leur réponse, mais tjrs pas fetch auprès de l'ip (qui est par ailleur mal interprétée)
User avatar
tom-garnier
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 57.1%
 
Posts: 58
Joined: 18 May 2024, 09:27
Location: Bretagne, France
Gender: Male
Calculator(s):
MyCalcs profile
GitHub: tom-garnier

Re: [LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+C

Unread postby elyas.creates » Today, 20:32

Avant que tu aie mis à jour la lib, ça fonctionnait correctement? Si c'est ça le problème je vais juste downgrade...
Projets en cours:
Omni Docs CE (disponible!)BrawlCEOmni Web CE
100%
50%
5%
User avatar
elyas.createsProgrammeur
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 84.4%
 
Posts: 28
Joined: 18 Sep 2024, 16:07
Gender: Male
Calculator(s):
MyCalcs profile
Class: 2nde

Re: [LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+C

Unread postby tom-garnier » Today, 20:44

Alors non justement, le problème avec moi est que cela n'a jamais fonctionné, cela a toujours crash sur la calculatrice
User avatar
tom-garnier
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 57.1%
 
Posts: 58
Joined: 18 May 2024, 09:27
Location: Bretagne, France
Gender: Male
Calculator(s):
MyCalcs profile
GitHub: tom-garnier

Re: [LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+C

Unread postby elyas.creates » 57 minutes ago

Moi aussi ça crash à chaque fois sauf avant d'update la lib une seule fois (sur 20) ça m'a affiché l'erreur 10
Projets en cours:
Omni Docs CE (disponible!)BrawlCEOmni Web CE
100%
50%
5%
User avatar
elyas.createsProgrammeur
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 84.4%
 
Posts: 28
Joined: 18 Sep 2024, 16:07
Gender: Male
Calculator(s):
MyCalcs profile
Class: 2nde

Re: [LIB C] INTERNETCE : Internet pour 83 Premium CE et 84+C

Unread postby tom-garnier » 52 minutes ago

L'erreur 20 apparaît si ton téléphone passe en veille, la communication se coupe.
Si tu regardes ce que j'ai expliqué, le problème est qu'il ne reçoit pas la réponse du serveur, car il ne l'envoie pas. Peut être y a-t-il un problème sur le format d'ip, mais en tout cas elle est bien connecté à internet. En modifiant les librairies j'ai réussi à "désactiver" temporairement la partie qui crash pour début le reste tranquillement
User avatar
tom-garnier
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 57.1%
 
Posts: 58
Joined: 18 May 2024, 09:27
Location: Bretagne, France
Gender: Male
Calculator(s):
MyCalcs profile
GitHub: tom-garnier

Previous

Return to Langages alternatifs

Who is online

Users browsing this forum: No registered users and 6 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1870 utilisateurs:
>1830 invités
>32 membres
>8 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)