diff --git a/CMakeLists.txt b/CMakeLists.txt index 56579ef33..64da181df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,8 @@ add_definitions(-DHAVE_FVISIBILITY=1 -DLOCALEDIR="${LOCALEDIR}") check_symbol_exists(ctime_r "time.h" HAVE_CTIME_R) check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R) check_symbol_exists(asctime_r "time.h" HAVE_ASCTIME_R) +check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R) +check_symbol_exists(strtok_s "string.h" HAVE_STRTOK_S) if(HAVE_CTIME_R) add_compile_definitions(HAVE_CTIME_R=1) endif() @@ -155,6 +157,12 @@ endif() if(HAVE_ASCTIME_R) add_compile_definitions(HAVE_ASCTIME_R=1) endif() +if(HAVE_STRTOK_R) +add_definitions(-DHAVE_STRTOK_R=1) +endif() +if(HAVE_STRTOK_S) +add_definitions(-DHAVE_STRTOK_S=1) +endif() # For libs finding find_package(PkgConfig) diff --git a/libticalcs/trunk/CMakeLists.txt b/libticalcs/trunk/CMakeLists.txt index ab69e5a86..8ccb0f36a 100644 --- a/libticalcs/trunk/CMakeLists.txt +++ b/libticalcs/trunk/CMakeLists.txt @@ -16,6 +16,7 @@ set(SRC_FILES src/calc_9x.cc src/calc_nsp.cc src/calc_xx.cc + src/calclabequipmentdata.cc src/clock.cc src/cmd68k.cc src/cmdz80.cc @@ -60,7 +61,8 @@ set(PUBLIC_HEADERS src/nsp_vpkt.h src/nsp_cmd.h src/cmdz80.h - src/cmd68k.h) + src/cmd68k.h + src/calclabequipmentdata.h) # external deps lookup if(TRY_STATIC_LIBS) diff --git a/libticalcs/trunk/configure.ac b/libticalcs/trunk/configure.ac index 81c9381da..511bb13e5 100644 --- a/libticalcs/trunk/configure.ac +++ b/libticalcs/trunk/configure.ac @@ -89,10 +89,11 @@ AC_CHECK_HEADERS([stdlib.h string.h time.h unistd.h]) AC_C_BIGENDIAN AC_C_CONST AC_C_RESTRICT +AX_CXX_COMPILE_STDCXX_11(noext, mandatory) # Checks for library functions. AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNCS([bzero memmove memset strcasecmp strdup localtime_r asctime_r]) +AC_CHECK_FUNCS([bzero memmove memset strcasecmp strdup localtime_r asctime_r strtok_r strtok_s]) # Platform specific tests. dnl AC_CANONICAL_HOST diff --git a/libticalcs/trunk/po/POTFILES.in b/libticalcs/trunk/po/POTFILES.in index 7e87133f0..4ac6e314c 100644 --- a/libticalcs/trunk/po/POTFILES.in +++ b/libticalcs/trunk/po/POTFILES.in @@ -1,6 +1,7 @@ # List of source files containing translatable strings. src/backup.cc +src/calclabequipmentdata.cc src/calc_00.cc src/calc_73.cc src/calc_84p.cc diff --git a/libticalcs/trunk/po/de.po b/libticalcs/trunk/po/de.po index def410adf..5104c3fdb 100644 --- a/libticalcs/trunk/po/de.po +++ b/libticalcs/trunk/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: libticalcs2 1.1.10\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: 2016-11-18 19:30+0300\n" "Last-Translator: Andreas B. Mundt \n" "Language-Team: German \n" @@ -20,15 +20,45 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/calc_00.cc:213 +#: src/calclabequipmentdata.cc:128 +msgid "Successfully parsed lab equipment data list string" +msgstr "" + +#: src/calclabequipmentdata.cc:138 +msgid "Failed to parse lab equipment data list string" +msgstr "" + +#: src/calclabequipmentdata.cc:334 src/calclabequipmentdata.cc:579 +#, c-format +msgid "Model %d is not known to support list data" +msgstr "" + +#: src/calclabequipmentdata.cc:343 +msgid "Expected TI-68k list or string format with this calculator model" +msgstr "" + +#: src/calclabequipmentdata.cc:349 +msgid "" +"Expected TI-Z80 or TI-85/86 list or string format with this calculator model" +msgstr "" + +#: src/calclabequipmentdata.cc:423 +msgid "List data too large, will not be sent" +msgstr "" + +#: src/calclabequipmentdata.cc:652 +msgid "Expected declared packet sizes to match" +msgstr "" + +#: src/calc_00.cc:225 msgid "Dummy hand-held" msgstr "Dummy Hand-Held" -#: src/calc_00.cc:214 +#: src/calc_00.cc:226 msgid "Dummy hand-held used when no calc is set" msgstr "Dummy Hand-Held verwendet, wenn kein calc gesetzt ist" -#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:402 +#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:422 #, c-format msgid "Parsing %s" msgstr "Lese und analysiere %s" @@ -37,13 +67,13 @@ msgstr "Lese und analysiere %s" msgid "Battery low, stopping flash app transfer" msgstr "Batteriespannung niedrig, breche den Transfer der Applikation ab" -#: src/calc_73.cc:856 src/calc_73.cc:1511 src/calc_9x.cc:1170 +#: src/calc_73.cc:856 src/calc_73.cc:1518 src/calc_9x.cc:1170 #: src/calc_89t.cc:514 #, c-format msgid "FLASH name: \"%s\"" msgstr "FLASH Name: \"%s\"" -#: src/calc_73.cc:857 src/calc_73.cc:1512 src/calc_9x.cc:1171 +#: src/calc_73.cc:857 src/calc_73.cc:1519 src/calc_9x.cc:1171 #: src/calc_89t.cc:515 #, c-format msgid "FLASH size: %i bytes." @@ -59,46 +89,50 @@ msgstr "Stelle Zeit..." msgid "Getting clock..." msgstr "Hole Zeit..." -#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1254 +#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1274 #: src/calc_9x.cc:1563 src/calc_9x.cc:1595 src/calc_89t.cc:980 #: src/calc_nsp.cc:852 #, c-format msgid "Deleting %s..." msgstr "Lösche %s..." -#: src/calc_73.cc:1483 src/calc_9x.cc:1722 src/calc_9x.cc:1755 +#: src/calc_73.cc:1485 src/calc_9x.cc:1720 src/calc_9x.cc:1758 #, c-format msgid " OS: %s" msgstr " OS: %s" -#: src/calc_73.cc:1484 src/calc_9x.cc:1723 +#: src/calc_73.cc:1486 src/calc_9x.cc:1721 #, c-format msgid " BIOS: %s" msgstr " BIOS: %s" -#: src/calc_73.cc:1485 +#: src/calc_73.cc:1487 #, c-format msgid " HW: %i" msgstr " HW: %i" -#: src/calc_73.cc:1486 src/calc_9x.cc:1724 src/calc_9x.cc:1756 +#: src/calc_73.cc:1488 src/calc_9x.cc:1722 src/calc_9x.cc:1759 #, c-format msgid " Battery: %s" msgstr " Batterie: %s" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "good" msgstr "gut" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "low" msgstr "niedrig" -#: src/calc_73.cc:1558 src/calc_9x.cc:1237 +#: src/calc_73.cc:1492 src/calc_9x.cc:1726 +msgid "Bad data length for version information" +msgstr "" + +#: src/calc_73.cc:1565 src/calc_9x.cc:1237 msgid "Header sent completely." msgstr "Header komplett gesendet." -#: src/calc_73.cc:1571 +#: src/calc_73.cc:1578 msgid "Receiving certificate" msgstr "Erhalte Zertifikat" @@ -156,39 +190,39 @@ msgstr "Unbekanntes 84+ Familienmitglied mit product_id=%d hw_version=%d" msgid "TI-84 Plus thru DirectLink" msgstr "TI-84 Plus mittels DirectLink" -#: src/calc_84p.cc:2149 +#: src/calc_84p.cc:2153 msgid "TI-84 Plus C Silver Edition thru DirectLink" msgstr "TI-84 Plus C Silver Edition mittels DirectLink" -#: src/calc_84p.cc:2220 +#: src/calc_84p.cc:2228 msgid "TI-83 Premium CE thru DirectLink" msgstr "TI-83 Premium CE mittels DirectLink" -#: src/calc_84p.cc:2291 +#: src/calc_84p.cc:2303 msgid "TI-84 Plus CE thru DirectLink" msgstr "TI-84 Plus CE mittels DirectLink" -#: src/calc_84p.cc:2362 +#: src/calc_84p.cc:2378 msgid "TI-82 Advanced thru DirectLink" msgstr "TI-82 Advanced mittels DirectLink" -#: src/calc_84p.cc:2433 +#: src/calc_84p.cc:2453 msgid "TI-84 Plus T thru DirectLink" msgstr "TI-84 Plus T mittels DirectLink" -#: src/calc_84p.cc:2504 +#: src/calc_84p.cc:2528 msgid "TI-82 Advanced Edition Python thru DirectLink" msgstr "TI-82 Advanced Edition Python mittels DirectLink" -#: src/calc_8x.cc:493 src/calc_8x.cc:803 +#: src/calc_8x.cc:513 src/calc_8x.cc:823 msgid "Waiting for user's action..." msgstr "Warte auf Aktion des Anwenders..." -#: src/calc_8x.cc:637 +#: src/calc_8x.cc:657 msgid "Waiting for backup..." msgstr "Warte auf Backup..." -#: src/calc_8x.cc:1075 +#: src/calc_8x.cc:1095 msgid "Waiting for var(s)..." msgstr "Warte auf var(s)..." @@ -217,7 +251,7 @@ msgstr "Block #%2i" msgid "Creating %s..." msgstr "Erzeuge %s..." -#: src/calc_9x.cc:2017 +#: src/calc_9x.cc:2032 msgid "V200 Personal Learning Tool" msgstr "V200 Persönliches Lernwerkzeug" @@ -255,59 +289,59 @@ msgstr "Nummeriere die Dokumente in %s nicht, weil es kein Verzeichnis ist\n" msgid "Directory listing in <%s>...\n" msgstr "Verzeichnisliste in <%s>...\n" -#: src/calc_nsp.cc:1201 +#: src/calc_nsp.cc:1203 msgid "Nspire thru DirectLink" msgstr "Nspire mittels DirectLink" -#: src/calc_nsp.cc:1215 +#: src/calc_nsp.cc:1217 msgid "Nspire Cradle thru DirectLink" msgstr "Nspire Cradle mittels DirectLink" -#: src/calc_nsp.cc:1229 +#: src/calc_nsp.cc:1231 msgid "Nspire Clickpad thru DirectLink" msgstr "Nspire Clickpad mittels DirectLink" -#: src/calc_nsp.cc:1243 +#: src/calc_nsp.cc:1245 msgid "Nspire Clickpad CAS thru DirectLink" msgstr "Nspire Clickpad CAS mittels DirectLink" -#: src/calc_nsp.cc:1257 +#: src/calc_nsp.cc:1259 msgid "Nspire Touchpad thru DirectLink" msgstr "Nspire Touchpad mittels DirectLink" -#: src/calc_nsp.cc:1271 +#: src/calc_nsp.cc:1273 msgid "Nspire Touchpad CAS thru DirectLink" msgstr "Nspire Touchpad CAS mittels DirectLink" -#: src/calc_nsp.cc:1285 +#: src/calc_nsp.cc:1287 msgid "Nspire CX thru DirectLink" msgstr "Nspire CX mittels DirectLink" -#: src/calc_nsp.cc:1299 +#: src/calc_nsp.cc:1301 msgid "Nspire CX CAS thru DirectLink" msgstr "Nspire CX CAS mittels DirectLink" -#: src/calc_nsp.cc:1313 +#: src/calc_nsp.cc:1315 msgid "Nspire CM-C thru DirectLink" msgstr "Nspire CM-C mittels DirectLink" -#: src/calc_nsp.cc:1327 +#: src/calc_nsp.cc:1329 msgid "Nspire CM-C CAS thru DirectLink" msgstr "Nspire CM-C CAS mittels DirectLink" -#: src/calc_nsp.cc:1341 +#: src/calc_nsp.cc:1343 msgid "Nspire CX II thru DirectLink" msgstr "Nspire CX II mittels DirectLink" -#: src/calc_nsp.cc:1355 +#: src/calc_nsp.cc:1357 msgid "Nspire CX II CAS thru DirectLink" msgstr "Nspire CX II CAS mittels DirectLink" -#: src/calc_nsp.cc:1369 +#: src/calc_nsp.cc:1371 msgid "Nspire CX II-T thru DirectLink" msgstr "Nspire CX II-T mittels DirectLink" -#: src/calc_nsp.cc:1383 +#: src/calc_nsp.cc:1385 msgid "Nspire CX II-T CAS thru DirectLink" msgstr "Nspire CX II-T CAS mittels DirectLink" @@ -439,6 +473,14 @@ msgstr "Sende fake (all vars) Backup:" msgid "Requesting fake (all vars) backup:" msgstr "Fordere fake (all vars) Backup an:" +#: src/calc_xx.cc:1497 +msgid "Sending lab equipment data:" +msgstr "" + +#: src/calc_xx.cc:1546 +msgid "Requesting lab equipment data:" +msgstr "" + #: src/dirlist.cc:194 msgid "| B. name | T. name |Attr|Type| Size | Folder |\n" msgstr "| B. Name | T. Name |Attr|Typ | Größe | Ordner |\n" @@ -856,51 +898,60 @@ msgstr "Msg: OS Upgrade-Typ nicht erkannt." msgid "Msg: anti-downgrade protection refuses this OS version." msgstr "Msg: Anti-Downgrade Protektion verhindert diese OS-Version." -#: src/probe.cc:91 +#: src/probe.cc:137 msgid "Probing calculator...\n" msgstr "Teste Rechner...\n" -#: src/probe.cc:95 +#: src/probe.cc:141 msgid "Check for TI86... " msgstr "Prüfe auf TI86... " -#: src/probe.cc:119 +#: src/probe.cc:165 msgid "Check for TI85... " msgstr "Prüfe auf TI85... " -#: src/probe.cc:143 +#: src/probe.cc:189 msgid "Check for TI73... " msgstr "Prüfe auf TI73... " -#: src/probe.cc:167 +#: src/probe.cc:213 msgid "Check for TI83... " msgstr "Prüfe auf TI83... " -#: src/probe.cc:191 +#: src/probe.cc:237 msgid "Check for TI82... " msgstr "Prüfe auf TI82... " -#: src/probe.cc:217 -msgid "Check for TI80... " -msgstr "Prüfe auf TI80... " +#: src/probe.cc:262 +msgid "Check for lab equipment... " +msgstr "" -#: src/probe.cc:273 +#: src/probe.cc:339 msgid "Check for TIXX... " msgstr "Prüfe auf TIXX... " -#: src/probe.cc:311 +#: src/probe.cc:345 +#, c-format +msgid "Found host (machine ID) %u" +msgstr "" + +#: src/probe.cc:368 msgid "Check for TI92... " msgstr "Prüfe auf TI92... " -#: src/probe.cc:355 +#: src/probe.cc:407 msgid "Check for TI9X... " msgstr "Prüfe auf TI9X... " -#: src/probe.cc:370 +#: src/probe.cc:431 msgid "Check for TI8X... " msgstr "Prüfe auf TI8X... " -#: src/probe.cc:385 +#: src/probe.cc:439 +msgid "Check for old lab equipment... " +msgstr "" + +#: src/probe.cc:452 #, c-format msgid "Calculator type: %s" msgstr "Rechner Typ: %s" @@ -910,16 +961,16 @@ msgstr "Rechner Typ: %s" msgid "Unknown pixel format %d\n" msgstr "Unbekanntes Pixel Format %d\n" -#: src/ticalcs.cc:324 +#: src/ticalcs.cc:360 #, c-format msgid "ticalcs library version %s" msgstr "ticalcs Library Version %s" -#: src/ticalcs.cc:640 +#: src/ticalcs.cc:679 msgid "Link calc handle details:" msgstr "Verbindungs-Details:" -#: src/ticalcs.cc:641 +#: src/ticalcs.cc:680 #, c-format msgid " model : %s" msgstr " Modell : %s" @@ -984,71 +1035,74 @@ msgstr "Boot2-Version: " msgid "OS Version: " msgstr "OS-Version: " -#: src/type2str.cc:317 +#: src/type2str.cc:318 msgid "Run level: " msgstr "Run level: " -#: src/type2str.cc:319 +#: src/type2str.cc:320 msgid "Clock speed: " msgstr "Taktfrequenz: " -#: src/type2str.cc:321 +#: src/type2str.cc:322 #, fuzzy msgid "Math capabilities (exact math engine): " msgstr "Genauer Math-Engine: " -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "Yes" msgstr "Ja" -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "No" msgstr "Nein" -#: src/type2str.cc:323 +#: src/type2str.cc:324 msgid "Python on board: " msgstr "" -#: src/type2str.cc:326 +#: src/type2str.cc:327 msgid "LCD width: " msgstr "LCD Breite: " -#: src/type2str.cc:328 +#: src/type2str.cc:329 msgid "LCD height: " msgstr "LCD Höhe: " -#: src/type2str.cc:330 +#: src/type2str.cc:331 msgid "Bits per pixel: " msgstr "Bits pro Pixel: " -#: src/type2str.cc:332 +#: src/type2str.cc:333 msgid "Color screen: " msgstr "Farb-Screen: " -#: src/type2str.cc:335 +#: src/type2str.cc:336 msgid "Physical RAM: " msgstr "Physikalischer RAM: " -#: src/type2str.cc:337 +#: src/type2str.cc:338 msgid "User RAM: " msgstr "Benutzer-RAM: " -#: src/type2str.cc:339 +#: src/type2str.cc:340 msgid "Free RAM: " msgstr "Freier RAM: " -#: src/type2str.cc:341 +#: src/type2str.cc:342 msgid "Physical Flash: " msgstr "Physikalischer Flash: " -#: src/type2str.cc:343 +#: src/type2str.cc:344 msgid "User Flash: " msgstr "Benutzer-Flash: " -#: src/type2str.cc:345 +#: src/type2str.cc:346 msgid "Free Flash: " msgstr "Freier Flash: " -#: src/type2str.cc:348 +#: src/type2str.cc:349 msgid "Battery: " msgstr " Batterie: " + +#~ msgid "Check for TI80... " +#~ msgstr "Prüfe auf TI80... " diff --git a/libticalcs/trunk/po/fr.po b/libticalcs/trunk/po/fr.po index e7e471380..5bc11b838 100644 --- a/libticalcs/trunk/po/fr.po +++ b/libticalcs/trunk/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libticalcs2 1.1.10\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: 2011-12-13 19:16+0100\n" "Last-Translator: Lionel Debroux \n" "Language-Team: Français \n" @@ -17,15 +17,53 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/calc_00.cc:213 +#: src/calclabequipmentdata.cc:128 +msgid "Successfully parsed lab equipment data list string" +msgstr "" +"Réussite de la lecture de la chaîne contenant une liste pour équipement de " +"laboratoire" + +#: src/calclabequipmentdata.cc:138 +msgid "Failed to parse lab equipment data list string" +msgstr "" +"Echec de la lecture de la chaîne contenant une liste pour équipement de " +"laboratoire" + +#: src/calclabequipmentdata.cc:334 src/calclabequipmentdata.cc:579 +#, c-format +msgid "Model %d is not known to support list data" +msgstr "" +"On n'est pas au courant que le modèle %d gère les données de type liste" + +#: src/calclabequipmentdata.cc:343 +msgid "Expected TI-68k list or string format with this calculator model" +msgstr "Format liste ou chaîne TI-68k attendu avec ce modèle de calculatrice" + +#: src/calclabequipmentdata.cc:349 +msgid "" +"Expected TI-Z80 or TI-85/86 list or string format with this calculator model" +msgstr "" +"Format liste ou chaîne TI-Z80 ou TI-85/86 attendu avec ce modèle de " +"calculatrice" + +#: src/calclabequipmentdata.cc:423 +msgid "List data too large, will not be sent" +msgstr "La liste est trop longue, elle ne sera pas envoyée" + +#: src/calclabequipmentdata.cc:652 +msgid "Expected declared packet sizes to match" +msgstr "" +"On s'attendait à ce que les tailles déclarées des paquets correspondent" + +#: src/calc_00.cc:225 msgid "Dummy hand-held" msgstr "Calculatrice vide" -#: src/calc_00.cc:214 +#: src/calc_00.cc:226 msgid "Dummy hand-held used when no calc is set" msgstr "Calculatrice vide utilisée quand aucune calculatrice n'est spécifiée" -#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:402 +#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:422 #, c-format msgid "Parsing %s" msgstr "Parcourt %s" @@ -34,13 +72,13 @@ msgstr "Parcourt %s" msgid "Battery low, stopping flash app transfer" msgstr "Batterie faible, arrêt du transfert de l'application Flash" -#: src/calc_73.cc:856 src/calc_73.cc:1511 src/calc_9x.cc:1170 +#: src/calc_73.cc:856 src/calc_73.cc:1518 src/calc_9x.cc:1170 #: src/calc_89t.cc:514 #, c-format msgid "FLASH name: \"%s\"" msgstr "Nom FLASH: \"%s\"" -#: src/calc_73.cc:857 src/calc_73.cc:1512 src/calc_9x.cc:1171 +#: src/calc_73.cc:857 src/calc_73.cc:1519 src/calc_9x.cc:1171 #: src/calc_89t.cc:515 #, c-format msgid "FLASH size: %i bytes." @@ -56,46 +94,50 @@ msgstr "Mise à jour de l'horloge..." msgid "Getting clock..." msgstr "Réception de l'horloge..." -#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1254 +#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1274 #: src/calc_9x.cc:1563 src/calc_9x.cc:1595 src/calc_89t.cc:980 #: src/calc_nsp.cc:852 #, c-format msgid "Deleting %s..." msgstr "Suppression de %s..." -#: src/calc_73.cc:1483 src/calc_9x.cc:1722 src/calc_9x.cc:1755 +#: src/calc_73.cc:1485 src/calc_9x.cc:1720 src/calc_9x.cc:1758 #, c-format msgid " OS: %s" msgstr " OS: %s" -#: src/calc_73.cc:1484 src/calc_9x.cc:1723 +#: src/calc_73.cc:1486 src/calc_9x.cc:1721 #, c-format msgid " BIOS: %s" msgstr " BIOS: %s" -#: src/calc_73.cc:1485 +#: src/calc_73.cc:1487 #, c-format msgid " HW: %i" msgstr " HW: %i" -#: src/calc_73.cc:1486 src/calc_9x.cc:1724 src/calc_9x.cc:1756 +#: src/calc_73.cc:1488 src/calc_9x.cc:1722 src/calc_9x.cc:1759 #, c-format msgid " Battery: %s" msgstr " Batterie: %s" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "good" msgstr "bon" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "low" msgstr "bas" -#: src/calc_73.cc:1558 src/calc_9x.cc:1237 +#: src/calc_73.cc:1492 src/calc_9x.cc:1726 +msgid "Bad data length for version information" +msgstr "Mauvaise longueur de données pour l'information de version" + +#: src/calc_73.cc:1565 src/calc_9x.cc:1237 msgid "Header sent completely." msgstr "En-tête envoyé complètement" -#: src/calc_73.cc:1571 +#: src/calc_73.cc:1578 msgid "Receiving certificate" msgstr "Réception du certificat" @@ -155,39 +197,39 @@ msgstr "Membre inconnu de la famille 84+ avec product_id=%d hw_version=%d" msgid "TI-84 Plus thru DirectLink" msgstr "TI-84 Plus via DirectLink" -#: src/calc_84p.cc:2149 +#: src/calc_84p.cc:2153 msgid "TI-84 Plus C Silver Edition thru DirectLink" msgstr "TI-84 Plus C Silver Edition via DirectLink" -#: src/calc_84p.cc:2220 +#: src/calc_84p.cc:2228 msgid "TI-83 Premium CE thru DirectLink" msgstr "TI-83 Premium CE via DirectLink" -#: src/calc_84p.cc:2291 +#: src/calc_84p.cc:2303 msgid "TI-84 Plus CE thru DirectLink" msgstr "TI-84 Plus CE via DirectLink" -#: src/calc_84p.cc:2362 +#: src/calc_84p.cc:2378 msgid "TI-82 Advanced thru DirectLink" msgstr "TI-82 Advanced via DirectLink" -#: src/calc_84p.cc:2433 +#: src/calc_84p.cc:2453 msgid "TI-84 Plus T thru DirectLink" msgstr "TI-84 Plus T via DirectLink" -#: src/calc_84p.cc:2504 +#: src/calc_84p.cc:2528 msgid "TI-82 Advanced Edition Python thru DirectLink" msgstr "TI-82 Advanced Edition Python via DirectLink" -#: src/calc_8x.cc:493 src/calc_8x.cc:803 +#: src/calc_8x.cc:513 src/calc_8x.cc:823 msgid "Waiting for user's action..." msgstr "Attente d'une action de la part de l'utilisateur..." -#: src/calc_8x.cc:637 +#: src/calc_8x.cc:657 msgid "Waiting for backup..." msgstr "En attente pour sauvegarder..." -#: src/calc_8x.cc:1075 +#: src/calc_8x.cc:1095 msgid "Waiting for var(s)..." msgstr "Attente de variable(s)..." @@ -216,7 +258,7 @@ msgstr "Bloc n°%2i" msgid "Creating %s..." msgstr "Création de %s..." -#: src/calc_9x.cc:2017 +#: src/calc_9x.cc:2032 msgid "V200 Personal Learning Tool" msgstr "V200 Personal Learning Tool" @@ -254,59 +296,59 @@ msgstr "N'énumère pas les documents dans %s car ce n'est pas un répertoire\n" msgid "Directory listing in <%s>...\n" msgstr "Listage du dossier dans <%s>...\n" -#: src/calc_nsp.cc:1201 +#: src/calc_nsp.cc:1203 msgid "Nspire thru DirectLink" msgstr "Nspire via DirectLink" -#: src/calc_nsp.cc:1215 +#: src/calc_nsp.cc:1217 msgid "Nspire Cradle thru DirectLink" msgstr "Nspire Cradle via DirectLink" -#: src/calc_nsp.cc:1229 +#: src/calc_nsp.cc:1231 msgid "Nspire Clickpad thru DirectLink" msgstr "Nspire Clickpad via DirectLink" -#: src/calc_nsp.cc:1243 +#: src/calc_nsp.cc:1245 msgid "Nspire Clickpad CAS thru DirectLink" msgstr "Nspire Clickpad CAS via DirectLink" -#: src/calc_nsp.cc:1257 +#: src/calc_nsp.cc:1259 msgid "Nspire Touchpad thru DirectLink" msgstr "Nspire Touchpad via DirectLink" -#: src/calc_nsp.cc:1271 +#: src/calc_nsp.cc:1273 msgid "Nspire Touchpad CAS thru DirectLink" msgstr "Nspire Touchpad CAS via DirectLink" -#: src/calc_nsp.cc:1285 +#: src/calc_nsp.cc:1287 msgid "Nspire CX thru DirectLink" msgstr "Nspire CX via DirectLink" -#: src/calc_nsp.cc:1299 +#: src/calc_nsp.cc:1301 msgid "Nspire CX CAS thru DirectLink" msgstr "Nspire CX CAS via DirectLink" -#: src/calc_nsp.cc:1313 +#: src/calc_nsp.cc:1315 msgid "Nspire CM-C thru DirectLink" msgstr "Nspire CM-C via DirectLink" -#: src/calc_nsp.cc:1327 +#: src/calc_nsp.cc:1329 msgid "Nspire CM-C CAS thru DirectLink" msgstr "Nspire CM-C CAS via DirectLink" -#: src/calc_nsp.cc:1341 +#: src/calc_nsp.cc:1343 msgid "Nspire CX II thru DirectLink" msgstr "Nspire CX II via DirectLink" -#: src/calc_nsp.cc:1355 +#: src/calc_nsp.cc:1357 msgid "Nspire CX II CAS thru DirectLink" msgstr "Nspire CX II CAS via DirectLink" -#: src/calc_nsp.cc:1369 +#: src/calc_nsp.cc:1371 msgid "Nspire CX II-T thru DirectLink" msgstr "Nspire CX II-T via DirectLink" -#: src/calc_nsp.cc:1383 +#: src/calc_nsp.cc:1385 msgid "Nspire CX II-T CAS thru DirectLink" msgstr "Nspire CX II-T CAS via DirectLink" @@ -438,6 +480,14 @@ msgstr "Envoi fausse sauvegarde (toutes les variables):" msgid "Requesting fake (all vars) backup:" msgstr "Réception fausse sauvegarde (toutes les variables):" +#: src/calc_xx.cc:1497 +msgid "Sending lab equipment data:" +msgstr "Envoi de données pour équipement de labo:" + +#: src/calc_xx.cc:1546 +msgid "Requesting lab equipment data:" +msgstr "Réception données équipement de labo:" + #: src/dirlist.cc:194 msgid "| B. name | T. name |Attr|Type| Size | Folder |\n" msgstr "|Nom Bin. |Nom Trad. |Attr|Type| Taille | Parent |\n" @@ -855,51 +905,60 @@ msgstr "Msg: type de mise à jour de l'OS non reconnu." msgid "Msg: anti-downgrade protection refuses this OS version." msgstr "Msg: la protection anti-retour refuse cette version d'OS" -#: src/probe.cc:91 +#: src/probe.cc:137 msgid "Probing calculator...\n" msgstr "Recherche calculatrice...\n" -#: src/probe.cc:95 +#: src/probe.cc:141 msgid "Check for TI86... " msgstr "Essai avec TI86... " -#: src/probe.cc:119 +#: src/probe.cc:165 msgid "Check for TI85... " msgstr "Essai avec TI85... " -#: src/probe.cc:143 +#: src/probe.cc:189 msgid "Check for TI73... " msgstr "Essai avec TI83... " -#: src/probe.cc:167 +#: src/probe.cc:213 msgid "Check for TI83... " msgstr "Essai avec TI83... " -#: src/probe.cc:191 +#: src/probe.cc:237 msgid "Check for TI82... " msgstr "Essai avec TI82... " -#: src/probe.cc:217 -msgid "Check for TI80... " -msgstr "Essai avec TI80... " +#: src/probe.cc:262 +msgid "Check for lab equipment... " +msgstr "Essai avec équipement de labo... " -#: src/probe.cc:273 +#: src/probe.cc:339 msgid "Check for TIXX... " msgstr "Essai avec TIXX... " -#: src/probe.cc:311 +#: src/probe.cc:345 +#, c-format +msgid "Found host (machine ID) %u" +msgstr "Trouvé l'hôte (ID machine) %u" + +#: src/probe.cc:368 msgid "Check for TI92... " msgstr "Essai avec TI92... " -#: src/probe.cc:355 +#: src/probe.cc:407 msgid "Check for TI9X... " msgstr "Essai avec TI9X... " -#: src/probe.cc:370 +#: src/probe.cc:431 msgid "Check for TI8X... " msgstr "Essai avec TI8X... " -#: src/probe.cc:385 +#: src/probe.cc:439 +msgid "Check for old lab equipment... " +msgstr "Essai de vieux équipements de labo..." + +#: src/probe.cc:452 #, c-format msgid "Calculator type: %s" msgstr " Type de calculatrice: %s" @@ -909,16 +968,16 @@ msgstr " Type de calculatrice: %s" msgid "Unknown pixel format %d\n" msgstr "Format de pixel %d inconnu\n" -#: src/ticalcs.cc:324 +#: src/ticalcs.cc:360 #, c-format msgid "ticalcs library version %s" msgstr "librairie ticalcs version %s" -#: src/ticalcs.cc:640 +#: src/ticalcs.cc:679 msgid "Link calc handle details:" msgstr "Détails du descripteur de calculatrice:" -#: src/ticalcs.cc:641 +#: src/ticalcs.cc:680 #, c-format msgid " model : %s" msgstr " modèle : %s" @@ -961,7 +1020,7 @@ msgstr "N° langue: " #: src/type2str.cc:303 msgid "User-defined ID: " -msgstr "ID défini par l'utilisateur" +msgstr "ID défini par l'utilisateur: " #: src/type2str.cc:306 msgid "Device Type: " @@ -983,70 +1042,73 @@ msgstr "Version du Boot2: " msgid "OS Version: " msgstr "Version de l'OS: " -#: src/type2str.cc:317 +#: src/type2str.cc:318 msgid "Run level: " msgstr "Niveau: " -#: src/type2str.cc:319 +#: src/type2str.cc:320 msgid "Clock speed: " msgstr "Vitesse d'horloge: " -#: src/type2str.cc:321 +#: src/type2str.cc:322 msgid "Math capabilities (exact math engine): " msgstr "Capacités mathématiques (moteur de calcul exact): " -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "Yes" msgstr "Oui" -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "No" msgstr "Non" -#: src/type2str.cc:323 +#: src/type2str.cc:324 msgid "Python on board: " msgstr "Python embarqué: " -#: src/type2str.cc:326 +#: src/type2str.cc:327 msgid "LCD width: " msgstr "Largeur écran: " -#: src/type2str.cc:328 +#: src/type2str.cc:329 msgid "LCD height: " msgstr "Hauteur écran: " -#: src/type2str.cc:330 +#: src/type2str.cc:331 msgid "Bits per pixel: " msgstr "Bits par pixel: " -#: src/type2str.cc:332 +#: src/type2str.cc:333 msgid "Color screen: " msgstr "Ecran couleur: " -#: src/type2str.cc:335 +#: src/type2str.cc:336 msgid "Physical RAM: " msgstr "RAM physique: " -#: src/type2str.cc:337 +#: src/type2str.cc:338 msgid "User RAM: " msgstr "RAM utilisateur: " -#: src/type2str.cc:339 +#: src/type2str.cc:340 msgid "Free RAM: " msgstr "RAM libre: " -#: src/type2str.cc:341 +#: src/type2str.cc:342 msgid "Physical Flash: " msgstr "Flash physique: " -#: src/type2str.cc:343 +#: src/type2str.cc:344 msgid "User Flash: " msgstr "Flash utilisateur: " -#: src/type2str.cc:345 +#: src/type2str.cc:346 msgid "Free Flash: " msgstr "Flash libre: " -#: src/type2str.cc:348 +#: src/type2str.cc:349 msgid "Battery: " msgstr "Batterie: " + +#~ msgid "Check for TI80... " +#~ msgstr "Essai avec TI80... " diff --git a/libticalcs/trunk/po/libticalcs2.pot b/libticalcs/trunk/po/libticalcs2.pot index 405732736..58426ba43 100644 --- a/libticalcs/trunk/po/libticalcs2.pot +++ b/libticalcs/trunk/po/libticalcs2.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libticalcs2 1.1.10\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,15 +17,45 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/calc_00.cc:213 +#: src/calclabequipmentdata.cc:128 +msgid "Successfully parsed lab equipment data list string" +msgstr "" + +#: src/calclabequipmentdata.cc:138 +msgid "Failed to parse lab equipment data list string" +msgstr "" + +#: src/calclabequipmentdata.cc:334 src/calclabequipmentdata.cc:579 +#, c-format +msgid "Model %d is not known to support list data" +msgstr "" + +#: src/calclabequipmentdata.cc:343 +msgid "Expected TI-68k list or string format with this calculator model" +msgstr "" + +#: src/calclabequipmentdata.cc:349 +msgid "" +"Expected TI-Z80 or TI-85/86 list or string format with this calculator model" +msgstr "" + +#: src/calclabequipmentdata.cc:423 +msgid "List data too large, will not be sent" +msgstr "" + +#: src/calclabequipmentdata.cc:652 +msgid "Expected declared packet sizes to match" +msgstr "" + +#: src/calc_00.cc:225 msgid "Dummy hand-held" msgstr "" -#: src/calc_00.cc:214 +#: src/calc_00.cc:226 msgid "Dummy hand-held used when no calc is set" msgstr "" -#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:402 +#: src/calc_73.cc:390 src/calc_84p.cc:303 src/calc_8x.cc:422 #, c-format msgid "Parsing %s" msgstr "" @@ -34,13 +64,13 @@ msgstr "" msgid "Battery low, stopping flash app transfer" msgstr "" -#: src/calc_73.cc:856 src/calc_73.cc:1511 src/calc_9x.cc:1170 +#: src/calc_73.cc:856 src/calc_73.cc:1518 src/calc_9x.cc:1170 #: src/calc_89t.cc:514 #, c-format msgid "FLASH name: \"%s\"" msgstr "" -#: src/calc_73.cc:857 src/calc_73.cc:1512 src/calc_9x.cc:1171 +#: src/calc_73.cc:857 src/calc_73.cc:1519 src/calc_9x.cc:1171 #: src/calc_89t.cc:515 #, c-format msgid "FLASH size: %i bytes." @@ -56,46 +86,50 @@ msgstr "" msgid "Getting clock..." msgstr "" -#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1254 +#: src/calc_73.cc:1409 src/calc_84p.cc:1656 src/calc_8x.cc:1274 #: src/calc_9x.cc:1563 src/calc_9x.cc:1595 src/calc_89t.cc:980 #: src/calc_nsp.cc:852 #, c-format msgid "Deleting %s..." msgstr "" -#: src/calc_73.cc:1483 src/calc_9x.cc:1722 src/calc_9x.cc:1755 +#: src/calc_73.cc:1485 src/calc_9x.cc:1720 src/calc_9x.cc:1758 #, c-format msgid " OS: %s" msgstr "" -#: src/calc_73.cc:1484 src/calc_9x.cc:1723 +#: src/calc_73.cc:1486 src/calc_9x.cc:1721 #, c-format msgid " BIOS: %s" msgstr "" -#: src/calc_73.cc:1485 +#: src/calc_73.cc:1487 #, c-format msgid " HW: %i" msgstr "" -#: src/calc_73.cc:1486 src/calc_9x.cc:1724 src/calc_9x.cc:1756 +#: src/calc_73.cc:1488 src/calc_9x.cc:1722 src/calc_9x.cc:1759 #, c-format msgid " Battery: %s" msgstr "" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "good" msgstr "" -#: src/calc_73.cc:1486 src/type2str.cc:349 +#: src/calc_73.cc:1488 src/type2str.cc:350 msgid "low" msgstr "" -#: src/calc_73.cc:1558 src/calc_9x.cc:1237 +#: src/calc_73.cc:1492 src/calc_9x.cc:1726 +msgid "Bad data length for version information" +msgstr "" + +#: src/calc_73.cc:1565 src/calc_9x.cc:1237 msgid "Header sent completely." msgstr "" -#: src/calc_73.cc:1571 +#: src/calc_73.cc:1578 msgid "Receiving certificate" msgstr "" @@ -149,39 +183,39 @@ msgstr "" msgid "TI-84 Plus thru DirectLink" msgstr "" -#: src/calc_84p.cc:2149 +#: src/calc_84p.cc:2153 msgid "TI-84 Plus C Silver Edition thru DirectLink" msgstr "" -#: src/calc_84p.cc:2220 +#: src/calc_84p.cc:2228 msgid "TI-83 Premium CE thru DirectLink" msgstr "" -#: src/calc_84p.cc:2291 +#: src/calc_84p.cc:2303 msgid "TI-84 Plus CE thru DirectLink" msgstr "" -#: src/calc_84p.cc:2362 +#: src/calc_84p.cc:2378 msgid "TI-82 Advanced thru DirectLink" msgstr "" -#: src/calc_84p.cc:2433 +#: src/calc_84p.cc:2453 msgid "TI-84 Plus T thru DirectLink" msgstr "" -#: src/calc_84p.cc:2504 +#: src/calc_84p.cc:2528 msgid "TI-82 Advanced Edition Python thru DirectLink" msgstr "" -#: src/calc_8x.cc:493 src/calc_8x.cc:803 +#: src/calc_8x.cc:513 src/calc_8x.cc:823 msgid "Waiting for user's action..." msgstr "" -#: src/calc_8x.cc:637 +#: src/calc_8x.cc:657 msgid "Waiting for backup..." msgstr "" -#: src/calc_8x.cc:1075 +#: src/calc_8x.cc:1095 msgid "Waiting for var(s)..." msgstr "" @@ -210,7 +244,7 @@ msgstr "" msgid "Creating %s..." msgstr "" -#: src/calc_9x.cc:2017 +#: src/calc_9x.cc:2032 msgid "V200 Personal Learning Tool" msgstr "" @@ -248,59 +282,59 @@ msgstr "" msgid "Directory listing in <%s>...\n" msgstr "" -#: src/calc_nsp.cc:1201 +#: src/calc_nsp.cc:1203 msgid "Nspire thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1215 +#: src/calc_nsp.cc:1217 msgid "Nspire Cradle thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1229 +#: src/calc_nsp.cc:1231 msgid "Nspire Clickpad thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1243 +#: src/calc_nsp.cc:1245 msgid "Nspire Clickpad CAS thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1257 +#: src/calc_nsp.cc:1259 msgid "Nspire Touchpad thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1271 +#: src/calc_nsp.cc:1273 msgid "Nspire Touchpad CAS thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1285 +#: src/calc_nsp.cc:1287 msgid "Nspire CX thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1299 +#: src/calc_nsp.cc:1301 msgid "Nspire CX CAS thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1313 +#: src/calc_nsp.cc:1315 msgid "Nspire CM-C thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1327 +#: src/calc_nsp.cc:1329 msgid "Nspire CM-C CAS thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1341 +#: src/calc_nsp.cc:1343 msgid "Nspire CX II thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1355 +#: src/calc_nsp.cc:1357 msgid "Nspire CX II CAS thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1369 +#: src/calc_nsp.cc:1371 msgid "Nspire CX II-T thru DirectLink" msgstr "" -#: src/calc_nsp.cc:1383 +#: src/calc_nsp.cc:1385 msgid "Nspire CX II-T CAS thru DirectLink" msgstr "" @@ -432,6 +466,14 @@ msgstr "" msgid "Requesting fake (all vars) backup:" msgstr "" +#: src/calc_xx.cc:1497 +msgid "Sending lab equipment data:" +msgstr "" + +#: src/calc_xx.cc:1546 +msgid "Requesting lab equipment data:" +msgstr "" + #: src/dirlist.cc:194 msgid "| B. name | T. name |Attr|Type| Size | Folder |\n" msgstr "" @@ -819,51 +861,60 @@ msgstr "" msgid "Msg: anti-downgrade protection refuses this OS version." msgstr "" -#: src/probe.cc:91 +#: src/probe.cc:137 msgid "Probing calculator...\n" msgstr "" -#: src/probe.cc:95 +#: src/probe.cc:141 msgid "Check for TI86... " msgstr "" -#: src/probe.cc:119 +#: src/probe.cc:165 msgid "Check for TI85... " msgstr "" -#: src/probe.cc:143 +#: src/probe.cc:189 msgid "Check for TI73... " msgstr "" -#: src/probe.cc:167 +#: src/probe.cc:213 msgid "Check for TI83... " msgstr "" -#: src/probe.cc:191 +#: src/probe.cc:237 msgid "Check for TI82... " msgstr "" -#: src/probe.cc:217 -msgid "Check for TI80... " +#: src/probe.cc:262 +msgid "Check for lab equipment... " msgstr "" -#: src/probe.cc:273 +#: src/probe.cc:339 msgid "Check for TIXX... " msgstr "" -#: src/probe.cc:311 +#: src/probe.cc:345 +#, c-format +msgid "Found host (machine ID) %u" +msgstr "" + +#: src/probe.cc:368 msgid "Check for TI92... " msgstr "" -#: src/probe.cc:355 +#: src/probe.cc:407 msgid "Check for TI9X... " msgstr "" -#: src/probe.cc:370 +#: src/probe.cc:431 msgid "Check for TI8X... " msgstr "" -#: src/probe.cc:385 +#: src/probe.cc:439 +msgid "Check for old lab equipment... " +msgstr "" + +#: src/probe.cc:452 #, c-format msgid "Calculator type: %s" msgstr "" @@ -873,16 +924,16 @@ msgstr "" msgid "Unknown pixel format %d\n" msgstr "" -#: src/ticalcs.cc:324 +#: src/ticalcs.cc:360 #, c-format msgid "ticalcs library version %s" msgstr "" -#: src/ticalcs.cc:640 +#: src/ticalcs.cc:679 msgid "Link calc handle details:" msgstr "" -#: src/ticalcs.cc:641 +#: src/ticalcs.cc:680 #, c-format msgid " model : %s" msgstr "" @@ -947,70 +998,70 @@ msgstr "" msgid "OS Version: " msgstr "" -#: src/type2str.cc:317 +#: src/type2str.cc:318 msgid "Run level: " msgstr "" -#: src/type2str.cc:319 +#: src/type2str.cc:320 msgid "Clock speed: " msgstr "" -#: src/type2str.cc:321 +#: src/type2str.cc:322 msgid "Math capabilities (exact math engine): " msgstr "" -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "Yes" msgstr "" -#: src/type2str.cc:322 src/type2str.cc:324 +#: src/type2str.cc:323 src/type2str.cc:325 msgid "No" msgstr "" -#: src/type2str.cc:323 +#: src/type2str.cc:324 msgid "Python on board: " msgstr "" -#: src/type2str.cc:326 +#: src/type2str.cc:327 msgid "LCD width: " msgstr "" -#: src/type2str.cc:328 +#: src/type2str.cc:329 msgid "LCD height: " msgstr "" -#: src/type2str.cc:330 +#: src/type2str.cc:331 msgid "Bits per pixel: " msgstr "" -#: src/type2str.cc:332 +#: src/type2str.cc:333 msgid "Color screen: " msgstr "" -#: src/type2str.cc:335 +#: src/type2str.cc:336 msgid "Physical RAM: " msgstr "" -#: src/type2str.cc:337 +#: src/type2str.cc:338 msgid "User RAM: " msgstr "" -#: src/type2str.cc:339 +#: src/type2str.cc:340 msgid "Free RAM: " msgstr "" -#: src/type2str.cc:341 +#: src/type2str.cc:342 msgid "Physical Flash: " msgstr "" -#: src/type2str.cc:343 +#: src/type2str.cc:344 msgid "User Flash: " msgstr "" -#: src/type2str.cc:345 +#: src/type2str.cc:346 msgid "Free Flash: " msgstr "" -#: src/type2str.cc:348 +#: src/type2str.cc:349 msgid "Battery: " msgstr "" diff --git a/libticalcs/trunk/src/Makefile.am b/libticalcs/trunk/src/Makefile.am index 98adae1e2..28a0918bc 100644 --- a/libticalcs/trunk/src/Makefile.am +++ b/libticalcs/trunk/src/Makefile.am @@ -11,7 +11,7 @@ libticalcsinclude_HEADERS = \ ticalcs.h export3.h \ keys73.h keys83.h keys83p.h keys86.h keys89.h keys92p.h \ dbus_pkt.h dusb_rpkt.h dusb_vpkt.h dusb_cmd.h nsp_rpkt.h nsp_vpkt.h nsp_cmd.h \ - cmdz80.h cmd68k.h romdump.h + cmdz80.h cmd68k.h romdump.h calclabequipmentdata.h # build instructions libticalcs2_la_CPPFLAGS = -I$(top_srcdir)/intl \ @@ -26,6 +26,7 @@ libticalcs2_la_SOURCES = *.h \ calc_73.cc calc_8x.cc calc_9x.cc \ calc_84p.cc calc_89t.cc \ calc_nsp.cc \ + calclabequipmentdata.cc \ clock.cc \ cmdz80.cc cmd68k.cc dusb_cmd.cc nsp_cmd.cc \ dirlist.cc \ diff --git a/libticalcs/trunk/src/calc_00.cc b/libticalcs/trunk/src/calc_00.cc index 0c0670c87..c9f296b3b 100644 --- a/libticalcs/trunk/src/calc_00.cc +++ b/libticalcs/trunk/src/calc_00.cc @@ -206,6 +206,18 @@ int noop_recv_all_vars_backup (CalcHandle* handle, FileContent* content) return 0; } +int noop_send_lab_equipment_data (CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data) +{ + (void)handle, (void)model, (void)data; + return 0; +} + +int noop_get_lab_equipment_data (CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data) +{ + (void)handle, (void)model, (void)data; + return 0; +} + extern const CalcFncts calc_00 = { CALC_NONE, @@ -242,7 +254,9 @@ extern const CalcFncts calc_00 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &noop_send_key, &noop_execute, @@ -271,5 +285,7 @@ extern const CalcFncts calc_00 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; diff --git a/libticalcs/trunk/src/calc_73.cc b/libticalcs/trunk/src/calc_73.cc index 141457fb8..e16fd5c9b 100644 --- a/libticalcs/trunk/src/calc_73.cc +++ b/libticalcs/trunk/src/calc_73.cc @@ -1454,36 +1454,43 @@ static int get_version (CalcHandle* handle, CalcInfos* infos) if (!ret) { memset(infos, 0, sizeof(CalcInfos)); - if (handle->model == CALC_TI73) + if (length >= 11) { - ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1x.%02x", buffer[0], buffer[1]); - ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1x.%02x", buffer[2], buffer[3]); + if (handle->model == CALC_TI73) + { + ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1x.%02x", buffer[0], buffer[1]); + ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1x.%02x", buffer[2], buffer[3]); + } + else + { + ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1i.%02i", buffer[0], buffer[1]); + ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1i.%02i", buffer[2], buffer[3]); + } + infos->battery = (buffer[4] & 1) ? 0 : 1; + infos->hw_version = buffer[5]; + switch(buffer[5]) + { + case 0: infos->model = CALC_TI83P; break; + case 1: infos->model = CALC_TI83P; break; + case 2: infos->model = CALC_TI84P; break; + case 3: infos->model = CALC_TI84P; break; + case 5: infos->model = CALC_TI84PC; break; + default: infos->model = CALC_TI84PC; break; // If new models ever arise, they'll probably be 84+CSE or newer anyway. + } + infos->language_id = buffer[6]; + infos->sub_lang_id = buffer[7]; + infos->mask = (InfosMask)(INFOS_BOOT_VERSION | INFOS_OS_VERSION | INFOS_BATTERY_ENOUGH | INFOS_HW_VERSION | INFOS_CALC_MODEL | INFOS_LANG_ID | INFOS_SUB_LANG_ID); + + tifiles_hexdump(buffer, length); + ticalcs_info(_(" OS: %s"), infos->os_version); + ticalcs_info(_(" BIOS: %s"), infos->boot_version); + ticalcs_info(_(" HW: %i"), infos->hw_version); + ticalcs_info(_(" Battery: %s"), infos->battery ? _("good") : _("low")); } else { - ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1i.%02i", buffer[0], buffer[1]); - ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1i.%02i", buffer[2], buffer[3]); - } - infos->battery = (buffer[4] & 1) ? 0 : 1; - infos->hw_version = buffer[5]; - switch(buffer[5]) - { - case 0: infos->model = CALC_TI83P; break; - case 1: infos->model = CALC_TI83P; break; - case 2: infos->model = CALC_TI84P; break; - case 3: infos->model = CALC_TI84P; break; - case 5: infos->model = CALC_TI84PC; break; - default: infos->model = CALC_TI84PC; break; // If new models ever arise, they'll probably be 84+CSE or newer anyway. - } - infos->language_id = buffer[6]; - infos->sub_lang_id = buffer[7]; - infos->mask = (InfosMask)(INFOS_BOOT_VERSION | INFOS_OS_VERSION | INFOS_BATTERY_ENOUGH | INFOS_HW_VERSION | INFOS_CALC_MODEL | INFOS_LANG_ID | INFOS_SUB_LANG_ID); - - tifiles_hexdump(buffer, length); - ticalcs_info(_(" OS: %s"), infos->os_version); - ticalcs_info(_(" BIOS: %s"), infos->boot_version); - ticalcs_info(_(" HW: %i"), infos->hw_version); - ticalcs_info(_(" Battery: %s"), infos->battery ? _("good") : _("low")); + ticalcs_warning("%s", _("Bad data length for version information")); + } } return ret; @@ -1630,7 +1637,7 @@ extern const CalcFncts calc_73 = "TI-73", "TI-73", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | - OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_VERSION | OPS_OS | + OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_VERSION | OPS_OS /*| OPS_LABEQUIPMENTDATA*/ | FTS_SILENT | FTS_MEMFREE | FTS_FLASH | FTS_BACKUP, PRODUCT_ID_TI73, {"", /* is_ready */ @@ -1661,7 +1668,9 @@ extern const CalcFncts calc_73 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1690,7 +1699,9 @@ extern const CalcFncts calc_73 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_83p = @@ -1700,7 +1711,7 @@ extern const CalcFncts calc_83p = "TI-83 Plus", "TI-83 Plus", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | - OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_DELVAR | OPS_VERSION | OPS_OS | + OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_DELVAR | OPS_VERSION | OPS_OS /*| OPS_LABEQUIPMENTDATA*/ | FTS_SILENT | FTS_MEMFREE | FTS_FLASH | FTS_CERT | FTS_BACKUP, PRODUCT_ID_TI83P, {"", /* is_ready */ @@ -1731,7 +1742,9 @@ extern const CalcFncts calc_83p = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1760,7 +1773,9 @@ extern const CalcFncts calc_83p = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_84p = @@ -1770,7 +1785,7 @@ extern const CalcFncts calc_84p = "TI-84 Plus", "TI-84 Plus", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | - OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_CLOCK | OPS_DELVAR | OPS_VERSION | OPS_OS | + OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_CLOCK | OPS_DELVAR | OPS_VERSION | OPS_OS /*| OPS_LABEQUIPMENTDATA*/ | FTS_SILENT | FTS_MEMFREE | FTS_FLASH | FTS_CERT | FTS_BACKUP, PRODUCT_ID_TI84P, {"", /* is_ready */ @@ -1801,7 +1816,9 @@ extern const CalcFncts calc_84p = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1830,7 +1847,9 @@ extern const CalcFncts calc_84p = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_84pcse = @@ -1840,7 +1859,7 @@ extern const CalcFncts calc_84pcse = "TI-84 Plus Color Silver Edition", "TI-84 Plus Color Silver Edition", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | - OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_CLOCK | OPS_DELVAR | OPS_VERSION | OPS_OS | + OPS_FLASH | OPS_IDLIST | OPS_ROMDUMP | OPS_CLOCK | OPS_DELVAR | OPS_VERSION | OPS_OS /*| OPS_LABEQUIPMENTDATA*/ | FTS_SILENT | FTS_MEMFREE | FTS_FLASH | FTS_CERT | FTS_BACKUP, PRODUCT_ID_TI84PCSE, {"", /* is_ready */ @@ -1871,7 +1890,9 @@ extern const CalcFncts calc_84pcse = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1900,5 +1921,7 @@ extern const CalcFncts calc_84pcse = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; diff --git a/libticalcs/trunk/src/calc_84p.cc b/libticalcs/trunk/src/calc_84p.cc index 88e890a10..d41a52889 100644 --- a/libticalcs/trunk/src/calc_84p.cc +++ b/libticalcs/trunk/src/calc_84p.cc @@ -2109,7 +2109,9 @@ extern const CalcFncts calc_84p_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2138,7 +2140,9 @@ extern const CalcFncts calc_84p_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_84pcse_usb = @@ -2180,7 +2184,9 @@ extern const CalcFncts calc_84pcse_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2209,7 +2215,9 @@ extern const CalcFncts calc_84pcse_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_83pce_usb = @@ -2251,7 +2259,9 @@ extern const CalcFncts calc_83pce_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2280,7 +2290,9 @@ extern const CalcFncts calc_83pce_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_84pce_usb = @@ -2322,7 +2334,9 @@ extern const CalcFncts calc_84pce_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2351,7 +2365,9 @@ extern const CalcFncts calc_84pce_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_82a_usb = @@ -2393,7 +2409,9 @@ extern const CalcFncts calc_82a_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2422,7 +2440,9 @@ extern const CalcFncts calc_82a_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_84pt_usb = @@ -2464,7 +2484,9 @@ extern const CalcFncts calc_84pt_usb = "", /* rename */ "", /* chattr */ "2P", /* send_all_vars_backup */ - "2P", /* recv_all_vars_backup */ }, + "2P", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2493,7 +2515,9 @@ extern const CalcFncts calc_84pt_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_82aep_usb = diff --git a/libticalcs/trunk/src/calc_89t.cc b/libticalcs/trunk/src/calc_89t.cc index cecd8c58c..d9ce86f60 100644 --- a/libticalcs/trunk/src/calc_89t.cc +++ b/libticalcs/trunk/src/calc_89t.cc @@ -1431,7 +1431,9 @@ extern const CalcFncts calc_89t_usb = "", /* rename */ "", /* chattr */ "2P1L", /* send_all_vars_backup */ - "2P1L" /* recv_all_vars_backup */ }, + "2P1L", /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1460,5 +1462,7 @@ extern const CalcFncts calc_89t_usb = &rename_var, &change_attr, &send_all_vars_backup, - &tixx_recv_all_vars_backup + &tixx_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; diff --git a/libticalcs/trunk/src/calc_8x.cc b/libticalcs/trunk/src/calc_8x.cc index 7256ec077..c30fc8373 100644 --- a/libticalcs/trunk/src/calc_8x.cc +++ b/libticalcs/trunk/src/calc_8x.cc @@ -28,11 +28,12 @@ #include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "ticalcs.h" #include "gettext.h" @@ -50,6 +51,7 @@ #include "keys83.h" #include "keys86.h" +#define SEND_RDY ti73_send_RDY #define SEND_KEY(handle, scancode) ((handle->model < CALC_TI85) ? ti82_send_KEY(handle, scancode) : ti85_send_KEY(handle, scancode)) #define SEND_SCR(handle) ((handle->model < CALC_TI85) ? ti82_send_SCR(handle) : ti85_send_SCR(handle)) #define SEND_ACK(handle) ((handle->model < CALC_TI85) ? ti82_send_ACK(handle) : ti85_send_ACK(handle)) @@ -86,6 +88,24 @@ #define TI86_ROWS 64 #define TI86_COLS 128 +static int is_ready (CalcHandle* handle) +{ + int ret; + uint16_t status; + + ret = SEND_RDY(handle); + if (!ret) + { + ret = RECV_ACK(handle, &status); + if (!ret) + { + ret = (MSB(status) & 0x01) ? ERR_NOT_READY : 0; + } + } + + return ret; +} + static int send_key (CalcHandle* handle, uint32_t key) { int ret; @@ -1283,6 +1303,91 @@ static int del_var (CalcHandle* handle, VarRequest* vr) return ret; } +static int get_version (CalcHandle* handle, CalcInfos* infos) +{ + int ret; + static CalcLabEquipmentData lab_equipment_data_1 = { CALC_LAB_EQUIPMENT_DATA_TYPE_STRING, 4, 1, (const uint8_t *)"{7}", 0, 0, 4 }; // Request status command. + CalcLabEquipmentData lab_equipment_data_2; + + // Use the TI-68k format because it's easier to deal with. + ret = tixx_send_lab_equipment_data(handle, CALC_TI89, &lab_equipment_data_1); + if (!ret) + { + ret = tixx_get_lab_equipment_data(handle, CALC_TI89, &lab_equipment_data_2); + if (!ret) + { + memset((void *)infos, 0, sizeof(*infos)); + if (lab_equipment_data_2.type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST) + { + uint32_t item_count; + const char * string_data; + double * raw_values; + // Parse list data to extract version number and other stuff, deducing the model. + ret = tixx_convert_lab_equipment_data_ti68k_raw_list_to_string(&lab_equipment_data_2, &item_count, &raw_values, &string_data); + if (!ret) + { + if (item_count >= 3) + { + unsigned int infos_mask = 0; + unsigned long device_code = (unsigned long)raw_values[0]; + + switch (device_code) + { + case 1UL: infos->model = CALC_CBL; break; + case 5UL: infos->model = CALC_CBL2; break; // This should be handled by another code path. + case 6UL: infos->model = CALC_LABPRO; break; // Ditto. + case 7UL: infos->model = CALC_TIPRESENTER; break; // Tentative value, ditto. + case 10UL: infos->model = CALC_CBR; break; + case 11UL: infos->model = CALC_CBR2; break; + default: ticalcs_critical("Unexpected device code %lu", device_code); break; + } + + ticalcs_info("Found model %d", infos->model); + if (infos->model == CALC_CBR || infos->model == CALC_CBR2 || infos->model == CALC_CBL2 || infos->model == CALC_LABPRO) + { + infos->battery = raw_values[2] > 0 ? 1 : 0; + if (infos->model == CALC_CBR || infos->model == CALC_CBR2) + { + sprintf(infos->os_version, "%04u", (unsigned int)(raw_values[0] * 10000)); + } + else + { + sprintf(infos->os_version, "%05u", (unsigned int)(raw_values[0] * 100000)); + } + infos_mask = INFOS_BATTERY | INFOS_OS_VERSION; + if (item_count >= 17) + { + sprintf(infos->user_defined_id, "%10.10g", raw_values[16]); + infos_mask |= INFOS_USER_DEFINED_ID; + } + } + if (infos->model != CALC_NONE) + { + infos_mask |= INFOS_CALC_MODEL; + } + infos->mask = (InfosMask)infos_mask; + } + else + { + ticalcs_warning("Expected at least 3 items in the list returned by the lab equipment"); + } + tixx_free_converted_lab_equipment_data_string((void *)string_data); + tixx_free_converted_lab_equipment_data_fpvals(raw_values); + } + } + else + { + // Internal error. + ticalcs_critical("XXX should have received TI-68k raw list"); + ret = ERR_INVALID_PARAMETER; + } + tifiles_hexdump(lab_equipment_data_2.data, lab_equipment_data_2.size); + } + } + + return ret; +} + extern const CalcFncts calc_80 = { CALC_TI80, @@ -1319,7 +1424,9 @@ extern const CalcFncts calc_80 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &noop_send_key, &noop_execute, @@ -1348,7 +1455,9 @@ extern const CalcFncts calc_80 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_82 = @@ -1357,7 +1466,7 @@ extern const CalcFncts calc_82 = "TI82", "TI-82", "TI-82", - OPS_SCREEN | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | + OPS_SCREEN | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | /*OPS_LABEQUIPMENTDATA |*/ FTS_BACKUP | FTS_NONSILENT, PRODUCT_ID_NONE, {"", /* is_ready */ @@ -1388,7 +1497,9 @@ extern const CalcFncts calc_82 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &noop_send_key, &noop_execute, @@ -1417,7 +1528,9 @@ extern const CalcFncts calc_82 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_83 = @@ -1427,7 +1540,7 @@ extern const CalcFncts calc_83 = "TI-83", "TI-83", OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | - OPS_DELVAR | + OPS_DELVAR | /*OPS_LABEQUIPMENTDATA |*/ FTS_SILENT | FTS_MEMFREE | FTS_BACKUP, PRODUCT_ID_NONE, {"", /* is_ready */ @@ -1458,7 +1571,9 @@ extern const CalcFncts calc_83 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &send_key, &execute, @@ -1487,7 +1602,9 @@ extern const CalcFncts calc_83 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_85 = @@ -1496,7 +1613,7 @@ extern const CalcFncts calc_85 = "TI85", "TI-85", "TI-85", - OPS_SCREEN | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | + OPS_SCREEN | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | /*OPS_LABEQUIPMENTDATA |*/ FTS_BACKUP | FTS_NONSILENT, PRODUCT_ID_NONE, {"", /* is_ready */ @@ -1527,7 +1644,9 @@ extern const CalcFncts calc_85 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &noop_send_key, &noop_execute, @@ -1556,7 +1675,9 @@ extern const CalcFncts calc_85 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; extern const CalcFncts calc_86 = @@ -1565,7 +1686,7 @@ extern const CalcFncts calc_86 = "TI86", "TI-86", "TI-86", - OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | + OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | /*OPS_LABEQUIPMENTDATA |*/ FTS_SILENT | FTS_MEMFREE | FTS_BACKUP, PRODUCT_ID_NONE, {"", /* is_ready */ @@ -1596,7 +1717,9 @@ extern const CalcFncts calc_86 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &noop_is_ready, &send_key, &noop_execute, @@ -1625,5 +1748,226 @@ extern const CalcFncts calc_86 = &noop_rename_var, &noop_change_attr, &noop_send_all_vars_backup, - &noop_recv_all_vars_backup + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data +}; + +extern const CalcFncts calc_cbl = +{ + CALC_CBL, + "CBL", + "CBL", + "CBL", + OPS_ISREADY | OPS_DIRLIST /*| OPS_VARS*/ | OPS_VERSION | OPS_LABEQUIPMENTDATA | + FTS_SILENT, + PRODUCT_ID_NONE, + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data +}; + +extern const CalcFncts calc_cbr = +{ + CALC_CBR, + "CBR", + "CBR", + "CBR", + OPS_ISREADY | OPS_DIRLIST /*| OPS_VARS*/ | OPS_VERSION | OPS_LABEQUIPMENTDATA | + FTS_SILENT, + PRODUCT_ID_NONE, + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data +}; + +extern const CalcFncts calc_cbr2 = +{ + CALC_CBR2, + "CBR2", + "CBR2", + "CBR2", + OPS_ISREADY | OPS_DIRLIST /*| OPS_VARS*/ | OPS_VERSION | OPS_LABEQUIPMENTDATA | + FTS_SILENT, + PRODUCT_ID_NONE, + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data }; diff --git a/libticalcs/trunk/src/calc_9x.cc b/libticalcs/trunk/src/calc_9x.cc index f599e180f..71f35913d 100644 --- a/libticalcs/trunk/src/calc_9x.cc +++ b/libticalcs/trunk/src/calc_9x.cc @@ -1697,31 +1697,34 @@ static int get_version (CalcHandle* handle, CalcInfos* infos) if (!ret) { memset(infos, 0, sizeof(CalcInfos)); - ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1d.%02d", buffer[0], buffer[1]); - ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1d.%02d", buffer[2], buffer[3]); - infos->battery = buffer[4] == 1 ? 0 : 1; - switch(buffer[13]) + if (length >= 14) { - case 1: - case 3: infos->hw_version = buffer[5] + 1; break; - case 8: infos->hw_version = buffer[5]; break; - case 9: infos->hw_version = buffer[5] + 1; break; + ticalcs_slprintf(infos->os_version, sizeof(infos->os_version), "%1d.%02d", buffer[0], buffer[1]); + ticalcs_slprintf(infos->boot_version, sizeof(infos->boot_version), "%1d.%02d", buffer[2], buffer[3]); + infos->battery = buffer[4] >= 1 ? 0 : 1; + switch(buffer[13]) + { + case 1: infos->hw_version = buffer[5] + 1; infos->model = CALC_TI92P; break; + case 3: infos->hw_version = buffer[5] + 1; infos->model = CALC_TI89; break; + case 5: infos->hw_version = buffer[5]; infos->model = CALC_CBL2; break; // Tentative + case 6: infos->hw_version = buffer[5]; infos->model = CALC_LABPRO; break; // Tentative + case 7: infos->hw_version = buffer[5]; infos->model = CALC_TIPRESENTER; break; // Tentative + case 8: infos->hw_version = buffer[5]; infos->model = CALC_V200; break; + case 9: infos->hw_version = buffer[5] + 1; infos->model = CALC_TI89T; break; + } + infos->language_id = buffer[6]; + infos->sub_lang_id = buffer[7]; + infos->mask = (InfosMask)(INFOS_BOOT_VERSION | INFOS_OS_VERSION | INFOS_BATTERY_ENOUGH | INFOS_HW_VERSION | INFOS_CALC_MODEL | INFOS_LANG_ID | INFOS_SUB_LANG_ID); + + tifiles_hexdump(buffer, length); + ticalcs_info(_(" OS: %s"), infos->os_version); + ticalcs_info(_(" BIOS: %s"), infos->boot_version); + ticalcs_info(_(" Battery: %s"), infos->battery ? "good" : "low"); } - switch(buffer[13]) + else { - case 1: infos->model = CALC_TI92P; break; - case 3: infos->model = CALC_TI89; break; - case 8: infos->model = CALC_V200; break; - case 9: infos->model = CALC_TI89T; break; + ticalcs_warning("%s", _("Bad data length for version information")); } - infos->language_id = buffer[6]; - infos->sub_lang_id = buffer[7]; - infos->mask = (InfosMask)(INFOS_BOOT_VERSION | INFOS_OS_VERSION | INFOS_BATTERY_ENOUGH | INFOS_HW_VERSION | INFOS_CALC_MODEL | INFOS_LANG_ID | INFOS_SUB_LANG_ID); - - tifiles_hexdump(buffer, length); - ticalcs_info(_(" OS: %s"), infos->os_version); - ticalcs_info(_(" BIOS: %s"), infos->boot_version); - ticalcs_info(_(" Battery: %s"), infos->battery ? "good" : "low"); } return ret; @@ -1796,7 +1799,7 @@ static int recv_cert (CalcHandle* handle, FlashContent* content) return ret; } -extern const CalcFncts calc_89 = +extern const CalcFncts calc_89 = { CALC_TI89, "TI89", @@ -1804,7 +1807,7 @@ extern const CalcFncts calc_89 = "TI-89", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_FLASH | OPS_IDLIST | OPS_CLOCK | OPS_ROMDUMP | - OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | + OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | OPS_LABEQUIPMENTDATA | FTS_SILENT | FTS_FOLDER | FTS_FLASH | FTS_CERT | FTS_NONSILENT, PRODUCT_ID_TI89, {"", /* is_ready */ @@ -1835,7 +1838,9 @@ extern const CalcFncts calc_89 = "", /* rename */ "", /* chattr */ "2P1L", /* send_all_vars_backup */ - "2P1L" /* recv_all_vars_backup */ }, + "2P1L" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1865,9 +1870,11 @@ extern const CalcFncts calc_89 = &noop_change_attr, &send_all_vars_backup, &tixx_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data }; -extern const CalcFncts calc_92p = +extern const CalcFncts calc_92p = { CALC_TI92P, "TI92+", @@ -1875,7 +1882,7 @@ extern const CalcFncts calc_92p = "TI-92 Plus", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_FLASH | OPS_IDLIST | OPS_CLOCK | OPS_ROMDUMP | - OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | + OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | OPS_LABEQUIPMENTDATA | FTS_SILENT | FTS_FOLDER | FTS_FLASH | FTS_CERT | FTS_NONSILENT, PRODUCT_ID_TI92P, {"", /* is_ready */ @@ -1906,7 +1913,9 @@ extern const CalcFncts calc_92p = "", /* rename */ "", /* chattr */ "2P1L", /* send_all_vars_backup */ - "2P1L" /* recv_all_vars_backup */ }, + "2P1L" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -1936,9 +1945,11 @@ extern const CalcFncts calc_92p = &noop_change_attr, &send_all_vars_backup, &tixx_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data }; -extern const CalcFncts calc_89t = +extern const CalcFncts calc_89t = { CALC_TI89T, "Titanium", @@ -1946,7 +1957,7 @@ extern const CalcFncts calc_89t = "TI-89 Titanium", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_FLASH | OPS_IDLIST | OPS_CLOCK | OPS_ROMDUMP | - OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | + OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | OPS_LABEQUIPMENTDATA | FTS_SILENT | FTS_FOLDER | FTS_FLASH | FTS_CERT | FTS_NONSILENT, PRODUCT_ID_TI89T, {"", /* is_ready */ @@ -1977,7 +1988,9 @@ extern const CalcFncts calc_89t = "", /* rename */ "", /* chattr */ "2P1L", /* send_all_vars_backup */ - "2P1L" /* recv_all_vars_backup */ }, + "2P1L" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2007,9 +2020,11 @@ extern const CalcFncts calc_89t = &noop_change_attr, &send_all_vars_backup, &tixx_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data }; -extern const CalcFncts calc_v2 = +extern const CalcFncts calc_v2 = { CALC_V200, "V200", @@ -2017,7 +2032,7 @@ extern const CalcFncts calc_v2 = N_("V200 Personal Learning Tool"), OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_FLASH | OPS_IDLIST | OPS_CLOCK | OPS_ROMDUMP | - OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | + OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_OS | OPS_LABEQUIPMENTDATA | FTS_SILENT | FTS_FOLDER | FTS_FLASH | FTS_CERT | FTS_NONSILENT, PRODUCT_ID_TIV200, {"", /* is_ready */ @@ -2048,7 +2063,9 @@ extern const CalcFncts calc_v2 = "", /* rename */ "", /* chattr */ "2P1L", /* send_all_vars_backup */ - "2P1L" /* recv_all_vars_backup */ }, + "2P1L" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2078,16 +2095,18 @@ extern const CalcFncts calc_v2 = &noop_change_attr, &send_all_vars_backup, &tixx_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data }; -extern const CalcFncts calc_92 = +extern const CalcFncts calc_92 = { CALC_TI92, "TI92", "TI-92", "TI-92", OPS_ISREADY | OPS_KEYS | OPS_SCREEN | OPS_DIRLIST | OPS_BACKUP | OPS_VARS | OPS_ROMDUMP | - OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | + OPS_DELVAR | OPS_NEWFLD | OPS_VERSION | OPS_LABEQUIPMENTDATA | FTS_SILENT | FTS_FOLDER | FTS_BACKUP | FTS_NONSILENT, PRODUCT_ID_NONE, {"", /* is_ready */ @@ -2118,7 +2137,9 @@ extern const CalcFncts calc_92 = "", /* rename */ "", /* chattr */ "", /* send_all_vars_backup */ - "" /* recv_all_vars_backup */ }, + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, &is_ready, &send_key, &execute, @@ -2148,4 +2169,227 @@ extern const CalcFncts calc_92 = &noop_change_attr, &noop_send_all_vars_backup, &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data +}; + +extern const CalcFncts calc_cbl2 = +{ + CALC_CBL2, + "CBL2", + "CBL2", + "CBL2", + OPS_ISREADY /*| OPS_DIRLIST | OPS_VARS*/ | + OPS_VERSION /*| OPS_OS*/ | OPS_LABEQUIPMENTDATA | + FTS_SILENT, + PRODUCT_ID_CBL2, + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &noop_get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data +}; + +extern const CalcFncts calc_labpro = +{ + CALC_LABPRO, + "LABPRO", + "LabPro", + "LabPro", + OPS_ISREADY /*| OPS_DIRLIST | OPS_VARS*/ | + OPS_VERSION /*| OPS_OS*/ | OPS_LABEQUIPMENTDATA | + FTS_SILENT, + PRODUCT_ID_LABPRO, + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &noop_get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &tixx_send_lab_equipment_data, + &tixx_get_lab_equipment_data +}; + +extern const CalcFncts calc_tipresenter = +{ + CALC_TIPRESENTER, + "TIPRESENTER", + "TI-Presenter", + "TI-Presenter", + OPS_ISREADY | OPS_VERSION /*| OPS_OS*/ | + FTS_SILENT, + PRODUCT_ID_NONE, // FIXME until this is determined. + {"", /* is_ready */ + "", /* send_key */ + "", /* execute */ + "", /* recv_screen */ + "", /* get_dirlist */ + "", /* get_memfree */ + "", /* send_backup */ + "", /* recv_backup */ + "", /* send_var */ + "", /* recv_var */ + "", /* send_var_ns */ + "", /* recv_var_ns */ + "", /* send_app */ + "", /* recv_app */ + "", /* send_os */ + "", /* recv_idlist */ + "", /* dump_rom_1 */ + "", /* dump_rom_2 */ + "", /* set_clock */ + "", /* get_clock */ + "", /* del_var */ + "", /* new_folder */ + "", /* get_version */ + "", /* send_cert */ + "", /* recv_cert */ + "", /* rename */ + "", /* chattr */ + "", /* send_all_vars_backup */ + "" /* recv_all_vars_backup */ + "", /* send_lab_equipment_data */ + "" /* get_lab_equipment_data */ }, + &is_ready, + &noop_send_key, + &noop_execute, + &noop_recv_screen, + &noop_get_dirlist, + &noop_get_memfree, + &noop_send_backup, + &noop_recv_backup, + &noop_send_var_ns, + &noop_recv_var, + &noop_send_var_ns, + &noop_recv_var_ns, + &noop_send_flash, + &noop_recv_flash, + &noop_send_os, + &noop_recv_idlist, + &noop_dump_rom_1, + &noop_dump_rom_2, + &noop_set_clock, + &noop_get_clock, + &noop_del_var, + &noop_new_folder, + &get_version, + &noop_send_cert, + &noop_recv_cert, + &noop_rename_var, + &noop_change_attr, + &noop_send_all_vars_backup, + &noop_recv_all_vars_backup, + &noop_send_lab_equipment_data, + &noop_get_lab_equipment_data }; diff --git a/libticalcs/trunk/src/calc_nsp.cc b/libticalcs/trunk/src/calc_nsp.cc index 65ef924a1..6673d0161 100644 --- a/libticalcs/trunk/src/calc_nsp.cc +++ b/libticalcs/trunk/src/calc_nsp.cc @@ -1190,7 +1190,9 @@ static int rename_var (CalcHandle* handle, VarRequest* oldname, VarRequest* new &rename_var, \ &noop_change_attr, \ &noop_send_all_vars_backup, \ - &tixx_recv_all_vars_backup \ + &tixx_recv_all_vars_backup, \ + &noop_send_lab_equipment_data, \ + &noop_get_lab_equipment_data \ } extern const CalcFncts calc_nsp = diff --git a/libticalcs/trunk/src/calc_xx.cc b/libticalcs/trunk/src/calc_xx.cc index 4b2be52a9..77a0e23d5 100644 --- a/libticalcs/trunk/src/calc_xx.cc +++ b/libticalcs/trunk/src/calc_xx.cc @@ -1468,9 +1468,105 @@ int TICALL ticalcs_calc_recv_all_vars_backup(CalcHandle* handle, FileContent* co return ret; } +/** + * ticalcs_calc_send_lab_equipment_data: + * @handle: a previously allocated handle + * @model: calculator model used by the computer + * @size: number of items in @data array + * @data: array of raw byte arrays. + * + * Send list data, i.e. Send({...}), for the models which support it. + * + * Return value: 0 if successful, an error code otherwise. + **/ +TIEXPORT3 int TICALL ticalcs_calc_send_lab_equipment_data(CalcHandle *handle, CalcModel model, CalcLabEquipmentData * lab_equipment_data) +{ + const CalcFncts *calc; + int ret = 0; -// --- + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(lab_equipment_data); + + calc = handle->calc; + VALIDATE_CALCFNCTS(calc); + + RETURN_IF_HANDLE_NOT_ATTACHED(handle); + RETURN_IF_HANDLE_NOT_OPEN(handle); + RETURN_IF_HANDLE_BUSY(handle); + + ticalcs_info("%s", _("Sending lab equipment data:")); + handle->busy = 1; + if (calc->fncts.send_lab_equipment_data) + { + CalcEventData event; + ticalcs_event_fill_header(handle, &event, /* type */ CALC_EVENT_TYPE_BEFORE_GENERIC_OPERATION, /* retval */ 0, /* operation */ FNCT_SEND_LAB_EQUIPMENT_DATA); + event.model = model; + ticalcs_event_fill_lab_equipment_data(&event, lab_equipment_data->type, lab_equipment_data->size, lab_equipment_data->items, lab_equipment_data->data, lab_equipment_data->index, lab_equipment_data->unknown, lab_equipment_data->vartype); + ret = ticalcs_event_send(handle, &event); + if (!ret) + { + ret = calc->fncts.send_lab_equipment_data(handle, model, lab_equipment_data); + } + ticalcs_event_fill_header(handle, &event, /* type */ CALC_EVENT_TYPE_AFTER_GENERIC_OPERATION, /* retval */ ret, /* operation */ FNCT_SEND_LAB_EQUIPMENT_DATA); + event.model = model; + ticalcs_event_fill_lab_equipment_data(&event, lab_equipment_data->type, lab_equipment_data->size, lab_equipment_data->items, lab_equipment_data->data, lab_equipment_data->index, lab_equipment_data->unknown, lab_equipment_data->vartype); + ret = ticalcs_event_send(handle, &event); + } + handle->busy = 0; + + return ret; +} + +/** + * ticalcs_calc_get_lab_equipment_data: + * @handle: a previously allocated handle + * @model: calculator model used by the computer + * @size: number of items in @data array + * @data: pointer to array of raw byte arrays. + * + * Get list data, i.e. Get , for the models which support it. + * + * Return value: 0 if successful, an error code otherwise. + **/ +TIEXPORT3 int TICALL ticalcs_calc_get_lab_equipment_data(CalcHandle *handle, CalcModel model, CalcLabEquipmentData * lab_equipment_data) +{ + const CalcFncts *calc; + int ret = 0; + + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(lab_equipment_data); + + calc = handle->calc; + VALIDATE_CALCFNCTS(calc); + + RETURN_IF_HANDLE_NOT_ATTACHED(handle); + RETURN_IF_HANDLE_NOT_OPEN(handle); + RETURN_IF_HANDLE_BUSY(handle); + + ticalcs_info("%s", _("Requesting lab equipment data:")); + handle->busy = 1; + if (calc->fncts.get_lab_equipment_data) + { + CalcEventData event; + ticalcs_event_fill_header(handle, &event, /* type */ CALC_EVENT_TYPE_BEFORE_GENERIC_OPERATION, /* retval */ 0, /* operation */ FNCT_GET_LAB_EQUIPMENT_DATA); + event.model = model; + memset((void *)&event.data.labeq_data, 0, sizeof(event.data.labeq_data)); + ret = ticalcs_event_send(handle, &event); + if (!ret) + { + ret = calc->fncts.get_lab_equipment_data(handle, model, lab_equipment_data); + } + ticalcs_event_fill_header(handle, &event, /* type */ CALC_EVENT_TYPE_AFTER_GENERIC_OPERATION, /* retval */ ret, /* operation */ FNCT_GET_LAB_EQUIPMENT_DATA); + event.model = model; + ticalcs_event_fill_lab_equipment_data(&event, lab_equipment_data->type, lab_equipment_data->size, lab_equipment_data->items, lab_equipment_data->data, lab_equipment_data->index, lab_equipment_data->unknown, lab_equipment_data->vartype); + ret = ticalcs_event_send(handle, &event); + } + handle->busy = 0; + return ret; +} + +// --- /** * ticalcs_calc_send_backup2: @@ -1823,7 +1919,7 @@ int TICALL ticalcs_calc_send_cert2(CalcHandle* handle, const char* filename) * @handle: a previously allocated handle * @filename: name of file * - * Send a FLASH app. + * Send an OS. * * Return value: 0 if successful, an error code otherwise. **/ @@ -1851,6 +1947,109 @@ int TICALL ticalcs_calc_send_os2(CalcHandle* handle, const char* filename) return ret; } +/** + * ticalcs_calc_send_lab_equipment_data2: + * @handle: a previously allocated handle + * @model: calculator model used by the computer + * @data: list data in convenient text form + * + * Send list data, i.e. Send({...}), for the models which support it. + * + * Return value: 0 if successful, an error code otherwise. + **/ +TIEXPORT3 int TICALL ticalcs_calc_send_lab_equipment_data2(CalcHandle *handle, CalcModel model, uint8_t vartype, const char * data) +{ + int ret; + CalcLabEquipmentData lab_equipment_data; + + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(data); + + RETURN_IF_HANDLE_NOT_ATTACHED(handle); + RETURN_IF_HANDLE_NOT_OPEN(handle); + RETURN_IF_HANDLE_BUSY(handle); + + lab_equipment_data.type = CALC_LAB_EQUIPMENT_DATA_TYPE_STRING; + lab_equipment_data.size = strlen(data) + 1; + lab_equipment_data.items = 0; + lab_equipment_data.data = (const uint8_t *)data; + lab_equipment_data.index = 0; + lab_equipment_data.unknown = 0; + lab_equipment_data.vartype = vartype; + ret = ticalcs_calc_send_lab_equipment_data(handle, model, &lab_equipment_data); + + return ret; +} + +/** + * ticalcs_calc_get_lab_equipment_data2: + * @handle: a previously allocated handle + * @model: calculator model used by the computer + * @data: pointer to output list data in convenient text form + * + * Get list data, i.e. Get , for the models which support it. + * + * Return value: 0 if successful, an error code otherwise. + **/ +TIEXPORT3 int TICALL ticalcs_calc_get_lab_equipment_data2(CalcHandle *handle, CalcModel model, uint8_t vartype, const char ** data) +{ + int ret; + CalcLabEquipmentData lab_equipment_data; + + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(data); + + RETURN_IF_HANDLE_NOT_ATTACHED(handle); + RETURN_IF_HANDLE_NOT_OPEN(handle); + RETURN_IF_HANDLE_BUSY(handle); + + lab_equipment_data.type = CALC_LAB_EQUIPMENT_DATA_TYPE_NONE; + lab_equipment_data.size = 0; + lab_equipment_data.items = 0; + lab_equipment_data.data = nullptr; + lab_equipment_data.index = 0; + lab_equipment_data.unknown = 0; + lab_equipment_data.vartype = vartype; + ret = ticalcs_calc_get_lab_equipment_data(handle, model, &lab_equipment_data); + if (!ret) + { + uint32_t item_count; + double * raw_values = nullptr; + if (lab_equipment_data.type == CALC_LAB_EQUIPMENT_DATA_TYPE_TIZ80_RAW_LIST) + { + ret = tixx_convert_lab_equipment_data_tiz80_raw_list_to_string(&lab_equipment_data, &item_count, &raw_values, data); + } + else if (lab_equipment_data.type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST) + { + ret = tixx_convert_lab_equipment_data_ti68k_raw_list_to_string(&lab_equipment_data, &item_count, &raw_values, data); + } + else if (lab_equipment_data.type == CALC_LAB_EQUIPMENT_DATA_TYPE_STRING) + { + // Shouldn't happen anyway, but if it does... just borrow data. + *data = (const char *)(lab_equipment_data.data); + } + else + { + // Internal error. + ret = ERR_INVALID_PARAMETER; + } + tixx_free_converted_lab_equipment_data_fpvals(raw_values); + } + + return ret; +} + +/** + * ticalcs_free_lab_equipment_data2: + * @data: previously allocated list data (string) + * + * Frees a string previously allocated by ticalcs_calc_get_lab_equipment_data2(). + */ +TIEXPORT3 void TICALL ticalcs_free_lab_equipment_data2(char * data) +{ + g_free((void *)data); +} + /** * ticalcs_calc_recv_cert2: * @handle: a previously allocated handle diff --git a/libticalcs/trunk/src/calc_xx.h b/libticalcs/trunk/src/calc_xx.h index d37cc141b..72af83c64 100644 --- a/libticalcs/trunk/src/calc_xx.h +++ b/libticalcs/trunk/src/calc_xx.h @@ -71,4 +71,11 @@ extern const CalcFncts calc_nsp_cxii_cas; extern const CalcFncts calc_nsp_cxiit; extern const CalcFncts calc_nsp_cxiit_cas; +extern const CalcFncts calc_cbl; +extern const CalcFncts calc_cbr; +extern const CalcFncts calc_cbl2; +extern const CalcFncts calc_cbr2; +extern const CalcFncts calc_labpro; +extern const CalcFncts calc_tipresenter; + #endif diff --git a/libticalcs/trunk/src/calclabequipmentdata.cc b/libticalcs/trunk/src/calclabequipmentdata.cc new file mode 100644 index 000000000..9667b6578 --- /dev/null +++ b/libticalcs/trunk/src/calclabequipmentdata.cc @@ -0,0 +1,818 @@ +/* Hey EMACS -*- linux-c -*- */ + +/* libticalcs2 - hand-helds support library, a part of the TILP project + * Copyright (C) 2019 Lionel Debroux + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + Send({...}) / Get support. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "ticalcs.h" +#include "gettext.h" +#include "internal.h" +#include "logging.h" +#include "error.h" + +#include "cmd68k.h" +#include "cmdz80.h" + +/////////////---------------- + +int tixx_convert_lab_equipment_data_string_to_ti8586_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data) +{ + int ret; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(out_data); + + ret = ERR_UNSUPPORTED; + + return ret; +} + +int tixx_convert_lab_equipment_data_string_to_tiz80_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data) +{ + int ret; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(out_data); + + ret = ERR_UNSUPPORTED; + + return ret; +} + +int tixx_convert_lab_equipment_data_string_to_ti68k_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data) +{ + int ret; + uint8_t * ptr; + uint8_t * orig_ptr; + unsigned int state; + uint32_t items; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(out_data); + + ptr = (uint8_t *)strdup(lab_equipment_data); + if (nullptr == ptr) + { + return ERR_MALLOC; + } + //fprintf(stderr, "%s\n", ptr); + + // Parse a reduced version of the original input form, i.e. the {...} inside Send(), without spaces or anything else (for now), and produce the + // [number of elements as 32-bit LE], [0x20 header], [characters making up the list with ',' replaced by ' '], [trailing 0x00] + // form which is transmitted on the wire by at least the 89, 92+, V200 and 89T (not checked the 92) for integer items. + // Simplified grammar: + // LIST: '{' BODY '}' + // BODY: NUMBER | (NUMBER ',')+ NUMBER + // NUMBER: [0-9]+ + // + // TODO perform more RE of the protocol using TIEmu, especially for floating-point numbers. + // TODO FIXME parse floating-point numbers as well. + // TODO FIXME convert leading - to unary minus, if necessary. + state = 0; + items = 0; + orig_ptr = ptr; + do + { + uint8_t c = *ptr; + switch (state) + { + // We'd need more states if we wanted to cope with spaces before and after '{', ',' and '}'. + case 0: + if (c == '{') { *ptr = ' '; state = 1; } // Read leading {, turn it into space and go on. + else state = 4; // else error + break; + case 1: + if (c >= '0' && c <= '9') { items++; state = 2; } // Read first digit, try to read more digits. + else state = 4; // else error + break; + case 2: + if (c >= '0' && c <= '9') state = 2; // Read more digits, try to read yet more digits. + else if (c == ',') { *ptr = ' '; state = 1; } // Read comma, turn it into space and go on. + else if (c == '}') { *ptr = 0; state = 3; } // Read trailing }, success + else state = 4; // else error. + break; + } + ptr++; + } while (state != 3 && state != 4); + + if (state == 3) + { + ticalcs_info("%s", _("Successfully parsed lab equipment data list string")); + out_data->type = CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST; + out_data->size = ptr - orig_ptr; + out_data->items = items; + out_data->data = (const uint8_t *)orig_ptr; + out_data->vartype = 4; // List. + ret = 0; + } + else + { + ticalcs_warning("%s", _("Failed to parse lab equipment data list string")); + ret = ERR_INVALID_PACKET; + } + + return ret; +} + +int tixx_convert_lab_equipment_data_ti8586_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * item_count, double ** raw_values, const char ** out_data) +{ + int ret; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(item_count); + VALIDATE_NONNULL(raw_values); + VALIDATE_NONNULL(out_data); + + ret = ERR_UNSUPPORTED; + + return ret; +} + +int tixx_convert_lab_equipment_data_tiz80_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * item_count, double ** raw_values, const char ** out_data) +{ + int ret; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(item_count); + VALIDATE_NONNULL(raw_values); + VALIDATE_NONNULL(out_data); + + ret = ERR_UNSUPPORTED; + + return ret; +} + +int tixx_convert_lab_equipment_data_ti68k_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * item_count, double ** raw_values, const char ** out_data) +{ + int ret; + uint16_t items; + const uint8_t * ptr; + uint8_t * ptr2; + char * deststr = nullptr; + size_t deststrsize; + size_t offset; + double * fpvals = nullptr; + struct lconv * lc; + const char * decimal_point_str; + size_t decimal_point_len; + + VALIDATE_NONNULL(lab_equipment_data); + VALIDATE_NONNULL(item_count); + VALIDATE_NONNULL(raw_values); + VALIDATE_NONNULL(out_data); + + *item_count = 0; + *raw_values = nullptr; + *out_data = nullptr; + + items = lab_equipment_data->items; + // A list of 32K items would be over 64 KB, which is invalid, due to max memory block / variable size. + if (items >= 32768) + { + return ERR_INVALID_PARAMETER; + } + else if (items == 0) + { + deststr = strdup("{}"); + if (nullptr == deststr) + { + return ERR_MALLOC; + } + *item_count = items; + // *raw_values already set above. + *out_data = deststr; + return 0; + } + + lc = localeconv(); + decimal_point_str = lc->decimal_point; + decimal_point_len = strlen(decimal_point_str); + + ptr = lab_equipment_data->data + 4; + deststrsize = strlen((const char *)ptr); + deststrsize += items * (decimal_point_len - 1); + deststr = (char *)malloc(deststrsize + 1); + if (nullptr == deststr) + { + return ERR_MALLOC; + } + strncpy(deststr, (const char *)ptr, deststrsize); + deststr[deststrsize] = 0; + + fpvals = (double *)malloc(items * sizeof(double)); + if (nullptr == fpvals) + { + ret = ERR_MALLOC; + goto err; + } + + ptr2 = (uint8_t *)strchr(deststr, '.'); + // Need to replace the decimal point. + if (decimal_point_str[0] != '.' || decimal_point_str[1] != 0) + { + while (nullptr != ptr2) + { + memmove(ptr2 + decimal_point_len, ptr2 + 1, (uint8_t *)deststr + deststrsize - ptr2 - 1); + strncpy((char *)ptr2, decimal_point_str, decimal_point_len); + ptr2 = (uint8_t *)strchr((const char *)ptr2 + 1, '.'); + } + //fprintf(stdout, "MM \"%s\"\n", deststr); + } + + ptr = (const uint8_t *)deststr; + while (*ptr == ' ') ptr++; + for (uint16_t i = 0; i < items && nullptr != ptr; i++) + { + char * endptr; + errno = 0; + fpvals[i] = strtod((const char *)ptr, &endptr); + if (errno != 0) + { + ret = ERR_INVALID_PACKET; + goto err; + } + ptr = (const uint8_t *)strchr((const char *)ptr + 1, ' '); + //ticalcs_info("L %g \"%s\" \"%s\"", fpvals[i], endptr, ptr); + } + ret = 0; + deststr[0] = '{'; + offset = 1; + for (uint16_t i = 0; i < items; i++) + { + int printed = sprintf(deststr + offset, "%g,", fpvals[i]); + offset += printed; + } + deststr[offset - 1] = '}'; + deststr[offset] = 0; + deststr = (char *)realloc(deststr, offset + 1); + + if (!ret) + { + deststr[offset] = '}'; + deststr[offset + 1] = 0; + deststr = (char *)realloc(deststr, offset + 2); + *item_count = items; + *raw_values = fpvals; + *out_data = deststr; + } + + return ret; + +err: + free(fpvals); + free(deststr); + return ret; +} + +void tixx_free_converted_lab_equipment_data_item(CalcLabEquipmentData * lab_equipment_data) +{ + if (nullptr != lab_equipment_data) + { + free((void *)(lab_equipment_data->data)); + } +} + +void tixx_free_converted_lab_equipment_data_string(void * lab_equipment_data) +{ + free(lab_equipment_data); +} + +void tixx_free_converted_lab_equipment_data_fpvals(double * raw_values) +{ + free(raw_values); +} + +/////////////---------------- + +int tixx_send_lab_equipment_data(CalcHandle* handle, CalcModel model, CalcLabEquipmentData * lab_equipment_data) +{ + int ret; + uint8_t target1; + uint8_t target2; + uint32_t size = 0; + uint32_t items = 0; + const uint8_t * ptr = nullptr; + int needs_destruction = 0; + uint8_t vartype; + + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(lab_equipment_data); + + target1 = ti68k_model_to_dbus_mid(model); + target2 = tiz80_model_to_dbus_mid(model); + + if (target1 == DBUS_MID_PC_TIXX && target2 == DBUS_MID_PC_TIXX) + { + ticalcs_critical(_("Model %d is not known to support list data"), model); + return ERR_INVALID_PARAMETER; + } + // target1 != 0 && target2 != 0 is an internal error. + + if (target1 != DBUS_MID_PC_TIXX && ( lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TIZ80_RAW_LIST + || lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI8586_RAW_LIST)) + { + // Wrong format. + ticalcs_warning("%s", _("Expected TI-68k list or string format with this calculator model")); + ret = ERR_INVALID_PARAMETER; + } + else if (target2 != DBUS_MID_PC_TIXX && lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST) + { + // Wrong format. + ticalcs_warning("%s", _("Expected TI-Z80 or TI-85/86 list or string format with this calculator model")); + ret = ERR_INVALID_PARAMETER; + } + else if (target1 != DBUS_MID_PC_TIXX && lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST) + { + // Will use TI-68k packet format. + // TODO check data format and item count. + ret = 0; + size = lab_equipment_data->size; + items = lab_equipment_data->items; + ptr = lab_equipment_data->data; + vartype = lab_equipment_data->vartype; + + if (vartype != 4) + { + ticalcs_critical("Variable type %u not supported for now", lab_equipment_data->vartype); + return ERR_INVALID_PARAMETER; + } + } + else if (target2 != DBUS_MID_PC_TIXX && lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TI8586_RAW_LIST) + { + // Will use TI-85/86 packet format. + // TODO check data format and item count. + ret = 0; + size = lab_equipment_data->size; + items = lab_equipment_data->items; + ptr = lab_equipment_data->data; + vartype = lab_equipment_data->vartype; + } + else if (target2 != DBUS_MID_PC_TIXX && lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_TIZ80_RAW_LIST) + { + // Will use TI-Z80 packet format. + // TODO check data format and item count. + ret = 0; + size = lab_equipment_data->size; + items = lab_equipment_data->items; + ptr = lab_equipment_data->data; + vartype = lab_equipment_data->vartype; + } + else if (lab_equipment_data->type == CALC_LAB_EQUIPMENT_DATA_TYPE_STRING) + { + CalcLabEquipmentData converted; + if (target1 != DBUS_MID_PC_TIXX) + { + ret = tixx_convert_lab_equipment_data_string_to_ti68k_raw_list((const char *)lab_equipment_data->data, &converted); + } + else + { + if (target2 == DBUS_MID_PC_TI85 || target2 == DBUS_MID_PC_TI86) + { + ret = tixx_convert_lab_equipment_data_string_to_ti8586_raw_list((const char *)lab_equipment_data->data, &converted); + } + else + { + ret = tixx_convert_lab_equipment_data_string_to_tiz80_raw_list((const char *)lab_equipment_data->data, &converted); + } + } + if (!ret) + { + needs_destruction = 1; + size = converted.size; + items = converted.items; + ptr = converted.data; + vartype = converted.vartype; + } + } + else + { + ticalcs_critical("This shouldn't occur, please report the issue"); + ret = ERR_INVALID_PARAMETER; + } + + if (size >= 65536) + { + ticalcs_critical("%s", _("List data too large, will not be sent")); + ret = ERR_INVALID_PARAMETER; + } + + if (ret) + { + goto end; + } + + if (target1 != DBUS_MID_PC_TIXX) + { +// Packets for Send({7}) from a TI-89. +/* +89 06 08 00 03 00 00 00 04 01 FF 00 07 01 +19 56 00 00 +19 09 00 00 +89 56 00 00 +89 15 07 00 01 00 00 00 20 37 00 58 00 +19 56 00 00 +89 92 00 00 +19 56 00 00 +*/ + do + { + uint8_t * ptr2; + ret = ti68k_send_VAR_lab_equipment_data(handle, size, vartype, target1); + if (ret) break; + + ret = ti89_recv_ACK(handle, NULL); + if (ret) break; + + ret = ti92_recv_CTS(handle); + if (ret) break; + + ret = ti68k_send_ACK(handle, target1); + if (ret) break; + + ticalcs_info("Sending \"%s\"", ptr); + + // Build number of items as 32-bit little-endian. + ptr2 = (uint8_t *)handle->buffer2; + ptr2[0] = items & 0xFF; + ptr2[1] = (items >> 8) & 0xFF; + ptr2[2] = (items >> 16) & 0xFF; + ptr2[3] = (items >> 24) & 0xFF; + memcpy(ptr2 + 4, ptr, size); + ret = ti68k_send_XDP(handle, size + 4, ptr2, target1); + if (ret) break; + + ret = ti89_recv_ACK(handle, NULL); + if (ret) break; + + ret = ti68k_send_EOT(handle, target1); + if (ret) break; + + ret = ti89_recv_ACK(handle, NULL); + } + while(0); + } + else + { + if (model == CALC_TI73) + { + // Will use TI-73 / TI-82 / TI-83 / TI-83+ packet format with TI-73 list numbering. + // TODO serialize data to newer TI-Z80 format. + // TODO implement sending newer TI-Z80 format packets. +// Packets for Send({7 from a TI-73: +/* +82 C9 0B 00 0B 00 01 5D 00 00 00 00 00 00 00 69 00 +12 56 00 00 +12 09 00 00 +82 56 00 00 +82 15 0B 00 01 00 00 80 70 00 00 00 00 00 00 F1 00 +12 56 00 00 +82 92 0B 00 [improper length] +12 56 00 00 +*/ + } + else if (model == CALC_TI82 || model == CALC_TI83) + { + // Will use TI-73 / TI-82 / TI-83 / TI-83+ packet format with TI-82/83 list numbering. + // TODO serialize data to newer TI-Z80 format. + // TODO implement sending newer TI-Z80 format packets. +// Packets for Send({7 from a TI-82 or TI-83: +/* +82 C9 0B 00 0B 00 01 5D 01 00 00 00 00 00 00 6A 00 +12 56 00 00 +12 09 00 00 +82 56 00 00 +82 15 0B 00 01 00 00 80 70 00 00 00 00 00 00 F1 00 +12 56 00 00 +82 92 0B 00 [improper length] +12 56 00 00 +*/ + } + else if (model == CALC_TI85 || model == CALC_TI86) + { + // Will use TI-85/86 packet format. + // TODO serialize data to TI-85/86 format. + // TODO implement sending TI-85/86 format packets. +// Packets for Send({7 from a TI-85 or TI-86: +/* +85 C9 0C 00 0C 00 04 01 42 00 00 00 00 00 00 00 53 00 +15 56 00 00 +15 09 00 00 +85 56 00 00 +85 15 0C 00 01 00 00 00 FC 70 00 00 00 00 00 00 6D 01 +15 56 00 00 +85 92 0C 00 [improper length] +15 56 00 00 +*/ + ret = ERR_UNSUPPORTED; + } + else + { + // Will use newer TI-Z80 packet format. + // TODO serialize data to newer TI-Z80 format. + // TODO implement sending newer TI-Z80 format packets. +// Packets for Send({7 from a 83+-class calculator. +/* +82 C9 0B 00 0B 00 01 24 00 00 00 00 00 00 00 30 00 +12 56 00 00 +12 09 00 00 +82 56 00 00 +82 15 0B 00 01 00 00 80 70 00 00 00 00 00 00 F1 00 +12 56 00 00 +82 92 0B 00 [improper length] +12 56 00 00 +*/ + ret = ERR_UNSUPPORTED; + } + } + +end: + if (needs_destruction) + { + tixx_free_converted_lab_equipment_data_string((void *)ptr); + } + + return ret; +} + +int tixx_get_lab_equipment_data(CalcHandle* handle, CalcModel model, CalcLabEquipmentData * lab_equipment_data) +{ + int ret; + uint8_t target1; + uint8_t target2; + + VALIDATE_HANDLE(handle); + VALIDATE_NONNULL(lab_equipment_data); + + target1 = ti68k_model_to_dbus_mid(model); + target2 = tiz80_model_to_dbus_mid(model); + + if (target1 == DBUS_MID_PC_TIXX && target2 == DBUS_MID_PC_TIXX) + { + ticalcs_critical(_("Model %d is not known to support list data"), model); + return ERR_INVALID_PARAMETER; + } + // target1 != 0 && target2 != 0 is an internal error. + + if (target1 != DBUS_MID_PC_TIXX) + { + // Will use TI-68k packet format. +// Packets for the Get corresponding to Send({7}) +/* +89 A2 06 00 00 00 00 00 04 00 04 00 +19 56 00 00 +19 06 06 00 E2 00 00 00 04 00 E6 00 +89 56 00 00 +89 09 00 00 +19 56 00 00 + +19 15 e2 00 11 00 00 00 +20 2b 35 2e 30 31 31 33 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 38 2e 38 38 38 30 30 45 2b 30 33 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 31 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 +20 2b 30 2e 30 30 30 30 30 45 2b 30 30 00 38 29 +89 56 00 00 +*/ + do + { + uint32_t varsize; + uint8_t vartype; + char varname[256 + 1]; + uint16_t length; + uint8_t * ptr; + + ret = ti92_send_REQ(handle, 0, 0x4, ""); + if (ret) break; + + ret = ti89_recv_ACK(handle, NULL); + if (ret) break; + + varname[0] = 0; + ret = ti92_recv_VAR(handle, &varsize, &vartype, varname); + if (ret) break; + if (vartype != 4 || varname[0] != 0) + { + ticalcs_critical("Unhandled VAR data format"); + break; + } + + ret = ti68k_send_ACK(handle, target1); + if (ret) break; + + ret = ti68k_send_CTS(handle, target1); + if (ret) break; + + ret = ti89_recv_ACK(handle, NULL); + if (ret) break; + + ret = ti68k_recv_XDP(handle, &length, (uint8_t *)handle->buffer2); + if (ret) break; + if (varsize != (uint32_t) length) + { + ticalcs_critical("%s", _("Expected declared packet sizes to match")); + ret = ERR_INVALID_PACKET; + } + + ret = ti68k_send_ACK(handle, target1); + if (ret) break; + + ptr = (uint8_t *)handle->buffer2; + lab_equipment_data->type = CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST; + lab_equipment_data->size = varsize; + lab_equipment_data->items = ptr[0] | (((uint16_t)ptr[1]) << 8); + lab_equipment_data->index = 0; + lab_equipment_data->unknown = 0; + lab_equipment_data->vartype = 4; + if (lab_equipment_data->items < 32768) + { + ptr = (uint8_t *)malloc(varsize); + if (nullptr != ptr) + { + memcpy(ptr, handle->buffer2, varsize); + lab_equipment_data->data = ptr; + } + else + { + ret = ERR_MALLOC; + } + } + else + { + ret = ERR_INVALID_PACKET; + } + } + while(0); + } + else + { + if (model == CALC_TI82) + { +// Packets for the Get(L1 corresponding to Send({7 from a TI-82: +/* +82 A2 0B 00 0B 00 00 5D 00 00 00 00 00 00 00 68 00 +12 56 00 00 +12 06 0B 00 9B 00 01 5D 00 00 00 00 00 00 00 F9 00 +82 56 0B 00 [improper length] +82 09 0B 00 [improper length] +12 56 00 00 +12 15 9B 00 11 00 +00 80 50 11 30 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 83 88 88 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 10 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 45 0a +82 56 9B 00 [improper length] +*/ + } + else if (model == CALC_TI85 || model == CALC_TI86) + { + // Will use TI-85/86 packet format. + // TODO implement code based on TilEm dumps. +// Packets for the Get(L1 (hopefully) corresponding to Send({7 from a TI-85 or TI-86: +/* +85 A2 0C 00 0C 00 04 01 43 00 00 00 00 00 00 00 54 00 +15 56 00 00 +15 06 05 00 AC 00 04 01 43 F4 00 +85 56 05 00 [improper length] +85 09 05 00 [improper length] +15 56 00 00 +15 15 AC 00 11 00 +00 00 FC 50 11 30 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 03 FC 88 88 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 10 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 81 12 +85 56 AC 00 [improper length] +*/ + ret = ERR_UNSUPPORTED; + } + else + { + // Will use TI-73 / TI-83 / TI-83+ packet format. + // TODO implement code based on TilEm + Wireshark USB dumps. +// Packets for the Get(L1 corresponding to Send({7 from a TI-83: +/* +95 A2 0B 00 0B 00 04 01 41 00 00 00 00 00 00 51 00 +15 56 00 00 +15 06 05 00 AC 00 04 01 41 F2 00 +95 56 05 00 [improper length] +95 09 05 00 [improper length] +15 56 00 00 +15 15 AC 00 11 00 +00 00 FC 50 11 30 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 03 FC 88 88 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 10 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 81 12 +95 56 AC 00 [improper length] +*/ +// Packets for the Get(L1 corresponding to Send({7 from a TI-73 or a TI-83+: +/* +95 A2 0B 00 0B 00 04 01 41 00 00 00 00 00 00 51 00 +15 56 00 00 +15 06 05 00 AC 00 04 01 41 F2 00 +95 56 00 00 +95 09 00 00 +15 56 00 00 +15 15 AC 00 11 00 +00 00 FC 50 11 30 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 03 FC 88 88 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 10 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 +00 00 FC 00 00 00 00 00 00 00 81 12 +95 56 00 00 +*/ + ret = ERR_UNSUPPORTED; + } + } + + return ret; +} diff --git a/libticalcs/trunk/src/calclabequipmentdata.h b/libticalcs/trunk/src/calclabequipmentdata.h new file mode 100644 index 000000000..4611be716 --- /dev/null +++ b/libticalcs/trunk/src/calclabequipmentdata.h @@ -0,0 +1,35 @@ +/* Hey EMACS -*- linux-c -*- */ + +/* libticalcs2 - hand-helds support library, a part of the TILP project + * Copyright (C) 2019 Lionel Debroux + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// /!\ NOTE: for this file, backwards compatibility will not necessarily be maintained as strongly as it is for ticalcs.h ! + +#ifndef __CALCLABEQUIPMENTDATA__ +#define __CALCLABEQUIPMENTDATA__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libticalcs/trunk/src/cmd68k.cc b/libticalcs/trunk/src/cmd68k.cc index 27ba40fa6..fc6c31d84 100644 --- a/libticalcs/trunk/src/cmd68k.cc +++ b/libticalcs/trunk/src/cmd68k.cc @@ -45,6 +45,11 @@ uint8_t TICALL ti68k_model_to_dbus_mid(CalcModel model) { case CALC_TI89: case CALC_TI89T: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: retval = DBUS_MID_PC_TI89; break; case CALC_TI92: retval = DBUS_MID_PC_TI92; break; @@ -52,6 +57,8 @@ uint8_t TICALL ti68k_model_to_dbus_mid(CalcModel model) retval = DBUS_MID_PC_TI92p; break; case CALC_V200: retval = DBUS_MID_PC_V200; break; + case CALC_TIPRESENTER: + retval = DBUS_MID_PC_TIPRESENTER; break; default: retval = DBUS_MID_PC_TIXX; break; } @@ -129,6 +136,25 @@ int TICALL ti68k_send_VAR(CalcHandle* handle, uint32_t varsize, uint8_t vartype, return dbus_send(handle, target, DBUS_CMD_VAR, 6 + len + extra, buffer); } +int TICALL ti68k_send_VAR_lab_equipment_data(CalcHandle* handle, uint32_t varsize, uint8_t vartype, uint8_t target) +{ + uint8_t buffer[16]; + + VALIDATE_HANDLE(handle); + + buffer[0] = LSB(LSW(varsize)); + buffer[1] = MSB(LSW(varsize)); + buffer[2] = LSB(MSW(varsize)); + buffer[3] = MSB(MSW(varsize)); + buffer[4] = vartype; + buffer[5] = 0x01; + buffer[6] = 0xFF; + buffer[7] = 0x00; + + ticalcs_info(" PC->TI: Send({...}) (size=0x%08X=%i, id=%02X)", varsize, varsize, vartype); + return dbus_send(handle, target, DBUS_CMD_VAR, 8, buffer); +} + int TICALL ti68k_send_CTS(CalcHandle* handle, uint8_t target) { return ti68k_send_simple_cmd(handle, target, DBUS_CMD_CTS, "CTS", 2, NULL); diff --git a/libticalcs/trunk/src/cmd68k.h b/libticalcs/trunk/src/cmd68k.h index e50a9db8e..8e9f230a5 100644 --- a/libticalcs/trunk/src/cmd68k.h +++ b/libticalcs/trunk/src/cmd68k.h @@ -37,6 +37,7 @@ TIEXPORT3 uint8_t TICALL ti68k_handle_to_dbus_mid(CalcHandle * handle); /* TI-68k family, send functions */ TIEXPORT3 int TICALL ti68k_send_VAR(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char *varname, uint8_t target); +TIEXPORT3 int TICALL ti68k_send_VAR_lab_equipment_data(CalcHandle* handle, uint32_t varsize, uint8_t vartype, uint8_t target); TIEXPORT3 int TICALL ti68k_send_CTS(CalcHandle* handle, uint8_t target); TIEXPORT3 int TICALL ti68k_send_XDP(CalcHandle* handle, uint32_t length, uint8_t * data, uint8_t target); TIEXPORT3 int TICALL ti68k_send_ACK(CalcHandle* handle, uint8_t target); diff --git a/libticalcs/trunk/src/cmdz80.cc b/libticalcs/trunk/src/cmdz80.cc index b2aea9c6f..0811a46b6 100644 --- a/libticalcs/trunk/src/cmdz80.cc +++ b/libticalcs/trunk/src/cmdz80.cc @@ -496,6 +496,28 @@ int TICALL ti85_send_RTS(CalcHandle* handle, uint16_t varsize, uint8_t vartype, return 0; } +TIEXPORT3 int TICALL tiz80_send_RTS_lab_equipment_data(CalcHandle* handle, uint16_t varsize, uint8_t vartype, uint8_t target) +{ + uint8_t buffer[16]; + + VALIDATE_HANDLE(handle); + + buffer[ 0] = LSB(varsize); + buffer[ 1] = MSB(varsize); + buffer[ 2] = vartype; + buffer[ 3] = 0x24; + buffer[ 4] = 0x00; + buffer[ 5] = 0x00; + buffer[ 6] = 0x00; + buffer[ 7] = 0x00; + buffer[ 8] = 0x00; + buffer[ 9] = 0x00; + buffer[10] = 0x00; + + ticalcs_info(" PC->TI: Send({...}) (size=0x%04X=%i, id=%02X)", varsize, varsize, vartype); + return dbus_send(handle, target, DBUS_CMD_RTS, 11, buffer); +} + /* Send an invalid packet that causes the calc to execute assembly code stored in the most recently transferred variable. diff --git a/libticalcs/trunk/src/cmdz80.h b/libticalcs/trunk/src/cmdz80.h index 45e8545b6..dcf0b78ec 100644 --- a/libticalcs/trunk/src/cmdz80.h +++ b/libticalcs/trunk/src/cmdz80.h @@ -41,7 +41,14 @@ static inline uint8_t tiz80_handle_to_dbus_mid_7383p(CalcHandle * handle) static inline uint8_t tiz80_handle_to_dbus_mid_8283(CalcHandle * handle) { - return (handle != NULL) ? ((handle->model == CALC_TI82) ? DBUS_MID_PC_TI82 : DBUS_MID_PC_TI83) : 0; + return (handle != NULL) ? ( (handle->model == CALC_TI82) + || (handle->model == CALC_CBL) + || (handle->model == CALC_CBR) + || (handle->model == CALC_CBL2) + || (handle->model == CALC_CBR2) + || (handle->model == CALC_LABPRO) + || (handle->model == CALC_TIPRESENTER) + ? DBUS_MID_PC_TI82 : DBUS_MID_PC_TI83) : 0; } static inline uint8_t tiz80_handle_to_dbus_mid_8586(CalcHandle * handle) @@ -59,6 +66,7 @@ TIEXPORT3 int TICALL tiz80_send_ERR(CalcHandle* handle, uint8_t target); TIEXPORT3 int TICALL tiz80_send_SCR(CalcHandle* handle, uint8_t target); TIEXPORT3 int TICALL tiz80_send_KEY(CalcHandle* handle, uint16_t scancode, uint8_t target); TIEXPORT3 int TICALL tiz80_send_EOT(CalcHandle* handle, uint8_t target); +TIEXPORT3 int TICALL tiz80_send_RTS_lab_equipment_data(CalcHandle* handle, uint16_t varsize, uint8_t vartype, uint8_t target); /* TI-Z80 family, receive functions */ TIEXPORT3 int TICALL tiz80_recv_CTS(CalcHandle* handle, uint16_t length); diff --git a/libticalcs/trunk/src/dbus_pkt.cc b/libticalcs/trunk/src/dbus_pkt.cc index 3cf2825b4..9f16b14d2 100644 --- a/libticalcs/trunk/src/dbus_pkt.cc +++ b/libticalcs/trunk/src/dbus_pkt.cc @@ -81,32 +81,35 @@ typedef struct static const DBUSMachineInfo machine_types[] = { - { DBUS_MID_PC_TIXX, "PC>TI" }, // 0x00, also PC_TI80 - { DBUS_MID_PC_TI82, "PC>TI" }, // 0x02 - { DBUS_MID_PC_TI83, "PC>TI" }, // 0x03 - { DBUS_MID_PC_TI85, "PC>TI" }, // 0x05 - { DBUS_MID_PC_TI86, "PC>TI" }, // 0x06 - { DBUS_MID_PC_TI73, "PC>TI" }, // 0x07 - { DBUS_MID_PC_TI89, "PC>TI" }, // 0x08, also PC_TI89t / PC_TI92p / PC_V200 - { DBUS_MID_PC_TI92, "PC>TI" }, // 0x09 - - { DBUS_MID_CBL_TI73, "CBL>TI" }, // 0x12, also CBL_TI82 / CBL_TI83 / CBL_TI83p / CBL_TI84p - { DBUS_MID_CBL_TI85, "CBL>TI" }, // 0x15, also CBL_TI86 - { DBUS_MID_CBL_TI89, "CBL>TI" }, // 0x19, also CBL_TI89t / CBL_TI92 / CBL_TI92p / CBL_V200 - - { DBUS_MID_PC_TI83p, "PC>TI" }, // 0x23, also PC_TI84p - - { DBUS_MID_TI83p_PC, "TI>PC" }, // 0x73, also TI84p_PC - { DBUS_MID_TI73_PC, "TI>PC" }, // 0x74 - { DBUS_MID_TI80_PC, "TI>PC" }, // 0x80 - { DBUS_MID_TI82_PC, "TI>PC|TI_CBL" }, // 0x82, also TI82_CBL - { DBUS_MID_TI83_PC, "TI>PC" }, // 0x83 - { DBUS_MID_TI85_PC, "TI>PC|TI>CBL" }, // 0x85, also TI85_CBL / TI86_CBL - { DBUS_MID_TI86_PC, "TI>PC" }, // 0x86 - { DBUS_MID_TI92p_PC, "TI>PC" }, // 0x88, also V200_PC - { DBUS_MID_TI92_PC, "TI>PC|TI>CBL" }, // 0x89, also TI89_CBL / TI89T_CBL / TI92_CBL / TI82P_CBL / V200_CBL - { DBUS_MID_TI73_CBL, "TI>CBL" }, // 0x95, also TI893_CBL / TI83p_CBL / TI84p_CBL - { DBUS_MID_TI89_PC, "TI>PC" }, // 0x98, also TI89t_PC + { DBUS_MID_PC_TIXX, "PC>TI" }, // 0x00, also PC_TI80 + { DBUS_MID_PC_TI82, "PC>TI" }, // 0x02 + { DBUS_MID_PC_TI83, "PC>TI" }, // 0x03 + { DBUS_MID_PC_TI85, "PC>TI" }, // 0x05 + { DBUS_MID_PC_TI86, "PC>TI" }, // 0x06 + { DBUS_MID_PC_TI73, "PC>TI" }, // 0x07 + { DBUS_MID_PC_TI89, "PC>TI" }, // 0x08, also PC_TI89t / PC_TI92p / PC_V200 + { DBUS_MID_PC_TI92, "PC>TI" }, // 0x09 + + { DBUS_MID_CBL_TI73, "CBL>TI" }, // 0x12, also CBL_TI82 / CBL_TI83 / CBL_TI83p / CBL_TI84p + { DBUS_MID_CBL_TI85, "CBL>TI" }, // 0x15, also CBL_TI86 + { DBUS_MID_CBL_TI89, "CBL>TI" }, // 0x19, also CBL_TI89t / CBL_TI92 / CBL_TI92p / CBL_V200 + + { DBUS_MID_PC_TI83p, "PC>TI" }, // 0x23, also PC_TI84p + + { DBUS_MID_CBL2_PC, "CBL2>PC" }, // 0x42, also LABPRO_PC + { DBUS_MID_TIPRESENTER_PC, "TIPR>PC" }, // 0x43, also LABPRO_PC + + { DBUS_MID_TI83p_PC, "TI>PC" }, // 0x73, also TI84p_PC + { DBUS_MID_TI73_PC, "TI>PC" }, // 0x74 + { DBUS_MID_TI80_PC, "TI>PC" }, // 0x80 + { DBUS_MID_TI82_PC, "TI>PC|TI_CBL" }, // 0x82, also TI82_CBL + { DBUS_MID_TI83_PC, "TI>PC" }, // 0x83 + { DBUS_MID_TI85_PC, "TI>PC|TI>CBL" }, // 0x85, also TI85_CBL / TI86_CBL + { DBUS_MID_TI86_PC, "TI>PC" }, // 0x86 + { DBUS_MID_TI92p_PC, "TI>PC" }, // 0x88, also V200_PC + { DBUS_MID_TI92_PC, "TI>PC|TI>CBL" }, // 0x89, also TI89_CBL / TI89T_CBL / TI92_CBL / TI82P_CBL / V200_CBL + { DBUS_MID_TI73_CBL, "TI>CBL" }, // 0x95, also TI83_CBL / TI83p_CBL / TI84p_CBL + { DBUS_MID_TI89_PC, "TI>PC" }, // 0x98, also TI89t_PC }; @@ -375,7 +378,7 @@ int TICALL dbus_recv_data(CalcHandle *handle, uint16_t* length, uint8_t* data) int ret = 0; int i; uint16_t chksum; - uint8_t buf[4]; + uint8_t buf[4] = { 0, 0, 0, 0 }; int r, q; CalcEventData event; diff --git a/libticalcs/trunk/src/dbus_pkt.h b/libticalcs/trunk/src/dbus_pkt.h index 99bc9a603..b8503c335 100644 --- a/libticalcs/trunk/src/dbus_pkt.h +++ b/libticalcs/trunk/src/dbus_pkt.h @@ -102,6 +102,11 @@ extern "C" { #define DBUS_MID_CBL_V200 0x19 #define DBUS_MID_V200_CBL 0x89 +#define DBUS_MID_CBL2_PC 0x42 +#define DBUS_MID_LABPRO_PC 0x42 +#define DBUS_MID_PC_TIPRESENTER 0x33 +#define DBUS_MID_TIPRESENTER_PC 0x43 + // Command IDs /* * means there is data attached. diff --git a/libticalcs/trunk/src/internal.h b/libticalcs/trunk/src/internal.h index 87e033999..92196fb79 100644 --- a/libticalcs/trunk/src/internal.h +++ b/libticalcs/trunk/src/internal.h @@ -318,6 +318,7 @@ static inline void ticalcs_event_fill_header(CalcHandle * handle, CalcEventData event->attached = handle->attached; event->open = handle->open; event->operation = operation; + event->model = handle->model; } static inline void ticalcs_event_fill_dbus_pkt(CalcEventData * event, uint16_t length, uint8_t id, uint8_t cmd, uint8_t * data) @@ -374,6 +375,17 @@ static inline void ticalcs_event_fill_romdump_pkt(CalcEventData * event, uint16_ event->data.romdump_pkt.data = data; } +static inline void ticalcs_event_fill_lab_equipment_data(CalcEventData * event, CalcLabEquipmentDataType type, uint16_t size, uint16_t items, const uint8_t * data, uint16_t index, uint16_t unknown, uint8_t vartype) +{ + event->data.labeq_data.type = type; + event->data.labeq_data.size = size; + event->data.labeq_data.items = items; + event->data.labeq_data.data = data; + event->data.labeq_data.index = index; + event->data.labeq_data.unknown = unknown; + event->data.labeq_data.vartype = vartype; +} + static inline int ticalcs_event_send_simple_generic(CalcHandle * handle, CalcEventType type, int retval, CalcFnctsIdx operation) { int ret = retval; @@ -408,7 +420,9 @@ static inline int ticalcs_event_send(CalcHandle * handle, CalcEventData * event) return ret; } + // backup.c + int tixx_recv_all_vars_backup(CalcHandle* handle, FileContent* content); @@ -443,6 +457,8 @@ int noop_rename_var (CalcHandle* handle, VarRequest* oldname, VarRequest* newnam int noop_change_attr (CalcHandle* handle, VarRequest* vr, FileAttr attr); int noop_send_all_vars_backup (CalcHandle* handle, FileContent* content); int noop_recv_all_vars_backup (CalcHandle* handle, FileContent* content); +int noop_send_lab_equipment_data (CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data); +int noop_get_lab_equipment_data (CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data); // calc_xx.c @@ -473,4 +489,26 @@ int dusb_dissect_cmd_data(CalcModel model, FILE *f, const uint8_t * data, uint32 return ERR_INVALID_PARAMETER; \ } + +// calclabequipmentdata.cc + +int tixx_convert_lab_equipment_data_string_to_ti8586_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data); +int tixx_convert_lab_equipment_data_string_to_tiz80_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data); +int tixx_convert_lab_equipment_data_string_to_ti68k_raw_list(const char * lab_equipment_data, CalcLabEquipmentData * out_data); +int tixx_convert_lab_equipment_data_ti8586_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * out_item_count, double ** raw_values, const char ** out_data); +int tixx_convert_lab_equipment_data_tiz80_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * out_item_count, double ** raw_values, const char ** out_data); +int tixx_convert_lab_equipment_data_ti68k_raw_list_to_string(CalcLabEquipmentData * lab_equipment_data, uint32_t * out_item_count, double ** raw_values, const char ** out_data); +void tixx_free_converted_lab_equipment_data_item(CalcLabEquipmentData * lab_equipment_data); +void tixx_free_converted_lab_equipment_data_string(void * lab_equipment_data); +void tixx_free_converted_lab_equipment_data_fpvals(double * raw_values); + +int tixx_send_lab_equipment_data(CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data); +int tixx_get_lab_equipment_data(CalcHandle* handle, CalcModel model, CalcLabEquipmentData * data); + + +// ticalcs.cc + +int ticalcs_default_event_hook(CalcHandle * handle, uint32_t event_count, const CalcEventData * event, void * user_pointer); + + #endif // __TICALCS_INTERNAL__ diff --git a/libticalcs/trunk/src/probe.cc b/libticalcs/trunk/src/probe.cc index e654cf4b7..c99a58576 100644 --- a/libticalcs/trunk/src/probe.cc +++ b/libticalcs/trunk/src/probe.cc @@ -46,10 +46,9 @@ static int tixx_recv_ACK(CalcHandle* handle, uint8_t* mid) { uint8_t host = 0, cmd = 0; uint16_t length = 0; - uint8_t buffer[5]; int ret; - ret = dbus_recv(handle, &host, &cmd, &length, buffer); + ret = dbus_recv(handle, &host, &cmd, &length, (uint8_t *)handle->buffer2); if (!ret) { ticalcs_info(" TI->PC: ACK"); @@ -65,6 +64,53 @@ static int tixx_recv_ACK(CalcHandle* handle, uint8_t* mid) return ret; } +static int try_ready_command(CalcHandle * handle, uint8_t mid, uint8_t * host, uint8_t * cmd, uint16_t * length) +{ + int ret; + + for (unsigned int i = 0; i < 2; i++) + { + ticalcs_info(" PC->TI: RDY?"); + ret = dbus_send(handle, mid, DBUS_CMD_RDY, 2, NULL); + //uint8_t buf[4] = { mid, DBUS_CMD_RDY, 0, 0 }; + //ret = ticables_cable_send(handle->cable, buf, sizeof(buf)); + if (ret) + { + ticalcs_info("Not ready"); + continue; + } + + ret = dbus_recv(handle, host, cmd, length, (uint8_t *)handle->buffer2); + if (ret) + { + ticalcs_info("NOK"); + continue; + } + /*ret = dbus_recv_header(handle, host, cmd, length); + if (ret) + { + ticalcs_info("Header NOK"); + ticalcs_info("ret=%d host=%u cmd=%u length=%u", ret, *host, *cmd, *length); + continue; + } + ticalcs_info("Header OK"); + ticalcs_info("ret=%d host=%u cmd=%u length=%u", ret, *host, *cmd, *length); + + ret = dbus_recv_data(handle, length, (uint8_t *)handle->buffer2); + if (ret) + { + ticalcs_info("Data NOK"); + continue; + }*/ + + ticalcs_info(" TI->PC: ACK"); + tifiles_hexdump((uint8_t *)handle->buffer2, *length); + break; + } + + return ret; +} + /** * ticalcs_probe_calc_2: * @handle: a previously allocated handle @@ -93,7 +139,7 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) /* Test for a TI86 before a TI85 */ ticalcs_info("%s", _("Check for TI86... ")); - err = dbus_send(handle, DBUS_MID_PC_TI86, DBUS_CMD_SCR, 2, NULL); + err = dbus_send(handle, DBUS_MID_PC_TI86, DBUS_CMD_SCR, 0, NULL); if (err) { break; @@ -117,7 +163,7 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) /* Test for a TI85 */ ticalcs_info("%s", _("Check for TI85... ")); - err = dbus_send(handle, DBUS_MID_PC_TI85, DBUS_CMD_SCR, 2, NULL); + err = dbus_send(handle, DBUS_MID_PC_TI85, DBUS_CMD_SCR, 0, NULL); if (err) { break; @@ -141,7 +187,7 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) /* Test for a TI73 before a TI83 */ ticalcs_info("%s", _("Check for TI73... ")); - err = dbus_send(handle, DBUS_MID_PC_TI73, DBUS_CMD_SCR, 2, NULL); + err = dbus_send(handle, DBUS_MID_PC_TI73, DBUS_CMD_SCR, 0, NULL); if (err) { break; @@ -165,7 +211,7 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) /* Test for a TI83 before a TI82 */ ticalcs_info("%s", _("Check for TI83... ")); - err = dbus_send(handle, DBUS_MID_PC_TI83, DBUS_CMD_SCR, 2, NULL); + err = dbus_send(handle, DBUS_MID_PC_TI83, DBUS_CMD_SCR, 0, NULL); if (err) { break; @@ -189,7 +235,7 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) /* Test for a TI82 */ ticalcs_info("%s", _("Check for TI82... ")); - err = dbus_send(handle, DBUS_MID_PC_TI83, DBUS_CMD_SCR, 2, NULL); + err = dbus_send(handle, DBUS_MID_PC_TI83, DBUS_CMD_SCR, 0, NULL); if (err) { break; @@ -212,29 +258,49 @@ static int ticalcs_probe_calc_2(CalcHandle* handle, CalcModel* model) } #if 0 - /* Test for a TI80 */ -#pragma message("Warning: TI-80 DETECTION FAILS") - ticalcs_info("%s", _("Check for TI80... ")); - err = dbus_send(handle, DBUS_MID_PC_TI80, DBUS_CMD_SCR, 0, NULL); - if (err) + /* As a last resort, try probing with the EOT command, which might be supported by some older lab equipment */ + ticalcs_info("%s", _("Check for lab equipment... ")); { - break; - } - err = tixx_recv_ACK(handle, &data); + uint8_t host = 0, cmd = 0; + uint16_t status = 0; + err = try_ready_command(handle, DBUS_MID_PC_TI89, &host, &cmd, &status); + if (err) + { + break; + } - ticalcs_info("<%02X-%02X> ", DBUS_MID_PC_TI80, data); + ticalcs_info(" PC->TI: EOT"); + err = dbus_send(handle, DBUS_MID_TI92_PC, DBUS_CMD_EOT, 0, NULL); + if (err) + { + ticalcs_info("NOK.\n"); + ticables_cable_reset(handle->cable); + break; + } + err = tixx_recv_ACK(handle, &data); - if (!err && (data == DBUS_MID_TI80_PC)) - { - ticalcs_info("OK !\n"); - *model = CALC_TI80; - break; - } - else - { - ticalcs_info("NOK.\n"); - ticables_cable_reset(handle->cable); - PAUSE(DEAD_TIME); + ticalcs_info("<%02X-%02X> ", DBUS_MID_CBL_TI92, data); + + if (!err && (data == DBUS_MID_CBL_TI92)) + { + CalcInfos infos; + ticalcs_info("OK !\n"); + handle->model = CALC_CBL; + handle->calc = (CalcFncts *)&calc_cbl; + + memset(&infos, 0, sizeof(CalcInfos)); + if (ticalcs_calc_get_version(handle, &infos)) + { + break; + } + *model = infos.model; + } + else + { + ticalcs_info("NOK.\n"); + ticables_cable_reset(handle->cable); + PAUSE(DEAD_TIME); + } } #endif } while(0); @@ -258,8 +324,7 @@ static int ticalcs_probe_calc_1(CalcHandle* handle, CalcModel* model) { uint8_t host = 0, cmd = 0; uint16_t status = 0; - uint8_t buffer[256]; - int i, ret; + int ret; // init value *model = CALC_NONE; @@ -269,30 +334,15 @@ static int ticalcs_probe_calc_1(CalcHandle* handle, CalcModel* model) CalcInfos infos; // test for FLASH hand-helds (00 68 00 00 -> XX 56 00 00) - // where XX is 0x98: TI89/89t, 0x88: TI92+/V200, 0x73: TI83+/84+, 0x74: TI73 + // where XX is 0x98: TI89/89t, 0x88: TI92+/V200, 0x73: TI83+/84+, 0x74: TI73, + // 0x1n: CBL/CBR/CBR2, 0x42: CBL2/LabPro, (TBC 0x43: TI-Presenter). ticalcs_info("%s", _("Check for TIXX... ")); - for (i = 0; i < 2; i++) - { - ticalcs_info(" PC->TI: RDY?"); - ret = dbus_send(handle, DBUS_MID_PC_TIXX, DBUS_CMD_RDY, 2, NULL); - if (ret) - { - continue; - } - - ret = dbus_recv(handle, &host, &cmd, &status, buffer); - ticalcs_info(" TI->PC: ACK"); - if (ret) - { - continue; - } - - break; - } + ret = try_ready_command(handle, DBUS_MID_PC_TIXX, &host, &cmd, &status); // test for TI73 if (!ret) { + ticalcs_info(_("Found host (machine ID) %u"), host); if (host == DBUS_MID_TI73_PC) { *model = CALC_TI73; @@ -303,33 +353,23 @@ static int ticalcs_probe_calc_1(CalcHandle* handle, CalcModel* model) *model = CALC_TI92; break; } + else if (host == DBUS_MID_TIPRESENTER_PC) + { + // For now, only the TI-Presenter is guessed to use 0x43 (well, according to the OS upgrade file, anyway). + *model = CALC_TIPRESENTER; + //break; // Do not break because for now, we want get_version to be executed. + } + // 0x1n (CBL, CBR, CBR2) and 0x42 (CBL2, LabPro) will require further examination, fall through. } // test for TI92 (09 68 00 00 -> 89 56 00 00) - else if (ret) + else /*if (ret)*/ { ticalcs_info("%s", _("Check for TI92... ")); ticables_cable_reset(handle->cable); PAUSE(DEAD_TIME); // needed ! - for (i = 0; i < 2; i++) - { - ticalcs_info(" PC->TI: RDY?"); - ret = dbus_send(handle, DBUS_MID_PC_TI92, DBUS_CMD_RDY, 2, NULL); - if (ret) - { - continue; - } - - ret = dbus_recv(handle, &host, &cmd, &status, buffer); - ticalcs_info(" TI->PC: ACK"); - if (ret) - { - continue; - } - - break; - } + ret = try_ready_command(handle, DBUS_MID_PC_TI92, &host, &cmd, &status); if (!ret) { @@ -339,45 +379,72 @@ static int ticalcs_probe_calc_1(CalcHandle* handle, CalcModel* model) if (cmd != DBUS_CMD_ACK) { + ticalcs_info("Was not ACK"); ret = ERR_INVALID_CMD; - break; } - if ((status & 1) != 0) + if (ret) { - ret = ERR_NOT_READY; break; } - // test for TI9x FLASH hand-helds again (request version and analyze HW_ID) - if(!ret && (host != DBUS_MID_TI73_PC) && (host != DBUS_MID_TI83p_PC)) + memset(&infos, 0, sizeof(CalcInfos)); + + // Test for TI9x FLASH hand-helds and newer lab equipment models again (request version and analyze HW_ID). + // This whitelist might leave aside some unknown models which use TI-68k-class version support. + // However, given that at least CBR and CBR2 can advertise themselves as 0x83, 0x00, 0x18 or presumably other machine IDs >= 0x12 and <= 0x19, + // or 0x1D (???), depending on how they communicated before, it's probably better to make the default case trying to probe older lab equipment... + //if(!ret && (host != DBUS_MID_TI73_PC) && (host != DBUS_MID_TI83p_PC) && (host != DBUS_MID_CBL_TI73) && ((host < 0x12) || (host > 0x19))) + if ((host == DBUS_MID_TI89_PC) || (host == DBUS_MID_TI92_PC) || (host == DBUS_MID_TI92p_PC) || (host == DBUS_MID_CBL2_PC) || (host == DBUS_MID_TIPRESENTER_PC)) { - ticalcs_info("%s", _("Check for TI9X... ")); + if ((status & 1) != 0) + { + ticalcs_info("Status was %d", status); + ret = ERR_NOT_READY; + break; + } - handle->model = CALC_TI89; - handle->calc = (CalcFncts *)&calc_89; + ticalcs_info("%s", _("Check for TI9X... ")); - memset(&infos, 0, sizeof(CalcInfos)); - ret = ticalcs_calc_get_version(handle, &infos); - if (ret) + if (*model != CALC_TIPRESENTER) { - break; + handle->model = CALC_TI89; + handle->calc = (CalcFncts *)&calc_89; + } + else + { + handle->model = CALC_TIPRESENTER; + handle->calc = (CalcFncts *)&calc_tipresenter; } - *model = infos.model; } else { - ticalcs_info("%s", _("Check for TI8X... ")); - - handle->model = CALC_TI83P; - handle->calc = (CalcFncts *)&calc_83p; - - memset(&infos, 0, sizeof(CalcInfos)); - ret = ticalcs_calc_get_version(handle, &infos); - if (ret) + // test for TI-8x and older lab equipment + if (host == DBUS_MID_TI73_PC || host == DBUS_MID_TI83p_PC) { - break; + if ((status & 1) != 0) + { + ticalcs_info("Status was %d", status); + ret = ERR_NOT_READY; + break; + } + ticalcs_info("%s", _("Check for TI8X... ")); + handle->model = CALC_TI83P; + handle->calc = (CalcFncts *)&calc_83p; + } + else + { + // Do not pay attention to status, as e.g. the CBR sends xx 56 01 00. + + ticalcs_info("%s", _("Check for old lab equipment... ")); + handle->model = CALC_CBL; + handle->calc = (CalcFncts *)&calc_cbl; } + } + + ret = ticalcs_calc_get_version(handle, &infos); + if (!ret) + { *model = infos.model; } } while(0); @@ -423,6 +490,7 @@ int TICALL ticalcs_probe_calc(CableHandle* cable, CalcModel* model) calc.buffer2 = (uint8_t *)g_malloc(65536 + 6); calc.cable = cable; calc.open = !0; + calc.event_hook = ticalcs_default_event_hook; // first: search for FLASH hand-helds (fast) ret = ticalcs_probe_calc_1(&calc, model); @@ -476,6 +544,7 @@ int TICALL ticalcs_probe_usb_calc(CableHandle* cable, CalcModel* model) calc.buffer2 = (uint8_t *)g_malloc(65536 + 6); calc.cable = cable; calc.open = !0; + calc.event_hook = ticalcs_default_event_hook; if (cable->model == CABLE_SLV) { @@ -557,6 +626,7 @@ int TICALL ticalcs_probe(CableModel c_model, CablePort c_port, CalcModel* model, calc.buffer2 = (uint8_t *)g_malloc(65536 + 6); calc.cable = handle; calc.open = !0; + calc.event_hook = ticalcs_default_event_hook; ret = ticalcs_probe_calc_1(&calc, model); diff --git a/libticalcs/trunk/src/ticalcs.cc b/libticalcs/trunk/src/ticalcs.cc index 3cae0d815..132ab1508 100644 --- a/libticalcs/trunk/src/ticalcs.cc +++ b/libticalcs/trunk/src/ticalcs.cc @@ -157,6 +157,24 @@ static CalcFncts const *const calcs[] = #endif #ifndef NO_TI82AEP_USB &calc_82aep_usb, +#endif +#ifndef NO_CBL + &calc_cbl, +#endif +#ifndef NO_CBR + &calc_cbr, +#endif +#ifndef NO_CBL2 + &calc_cbl2, +#endif +#ifndef NO_CBR2 + &calc_cbr2, +#endif +#ifndef NO_LABPRO + &calc_labpro, +#endif +#ifndef NO_TIPRESENTER + &calc_tipresenter, #endif NULL }; @@ -271,6 +289,24 @@ static const uint64_t supported_calcs = #ifndef NO_TI82AEP_USB | (UINT64_C(1) << CALC_TI82AEP_USB) #endif +#ifndef NO_CBL + | (UINT64_C(1) << CALC_CBL) +#endif +#ifndef NO_CBR + | (UINT64_C(1) << CALC_CBR) +#endif +#ifndef NO_CBL2 + | (UINT64_C(1) << CALC_CBL2) +#endif +#ifndef NO_CBR2 + | (UINT64_C(1) << CALC_CBR2) +#endif +#ifndef NO_LABPRO + | (UINT64_C(1) << CALC_LABPRO) +#endif +#ifndef NO_TIPRESENTER + | (UINT64_C(1) << CALC_TIPRESENTER) +#endif ; static const uint32_t supported_protocols = @@ -408,7 +444,7 @@ uint32_t TICALL ticalcs_max_calc_function_idx(void) return CALC_FNCT_LAST; } -static int default_event_hook(CalcHandle * handle, uint32_t event_count, const CalcEventData * event, void * user_pointer) +int ticalcs_default_event_hook(CalcHandle * handle, uint32_t event_count, const CalcEventData * event, void * user_pointer) { (void)user_pointer; const char * calcstr = ticalcs_model_to_string(ticalcs_get_model(handle)); @@ -432,7 +468,7 @@ static int default_event_hook(CalcHandle * handle, uint32_t event_count, const C case CALC_EVENT_TYPE_BEFORE_CABLE_DETACH: break; case CALC_EVENT_TYPE_AFTER_CABLE_DETACH: { - ticalcs_info("Cable %s port %s detached", cablestr, portstr); + ticalcs_info("Cable %s port %s detached, retval %d", cablestr, portstr, event->retval); break; } @@ -441,6 +477,7 @@ static int default_event_hook(CalcHandle * handle, uint32_t event_count, const C if (pkt_debug) { ticalcs_info("Before PC->TI DBUS PKT operation for calc %s cable %s port %s", calcstr, cablestr, portstr); + ticalcs_info("DBUS PKT: target %u, cmd %u, length %u", event->data.dbus_pkt.id, event->data.dbus_pkt.cmd, event->data.dbus_pkt.length); } break; } @@ -450,7 +487,9 @@ static int default_event_hook(CalcHandle * handle, uint32_t event_count, const C { if (pkt_debug) { - ticalcs_info("After TI->PC DBUS PKT operation for calc %s cable %s port %s", calcstr, cablestr, portstr); + ticalcs_info("After TI->PC DBUS PKT operation %d for calc %s cable %s port %s, retval %d", event->type, calcstr, cablestr, portstr, event->retval); + ticalcs_info("DBUS PKT: target %u, cmd %u, length %u", event->data.dbus_pkt.id, event->data.dbus_pkt.cmd, event->data.dbus_pkt.length); + tifiles_hexdump(event->data.dbus_pkt.data, event->data.dbus_pkt.length); } break; } @@ -588,7 +627,7 @@ CalcHandle* TICALL ticalcs_handle_new(CalcModel model) handle->priv.nsp_src_port = 0x8001; handle->priv.nsp_dst_port = 0x4003; // NSP_PORT_ADDR_REQUEST - handle->event_hook = default_event_hook; + handle->event_hook = ticalcs_default_event_hook; //handle->event_count = 0; handle->buffer = (uint8_t *)g_malloc(65536 + 6); @@ -867,7 +906,11 @@ int TICALL ticalcs_model_supports_installing_flashapps(CalcModel model) return ticonv_model_has_flash_memory(model) && !( model == CALC_TI82A_USB || model == CALC_TI84PT_USB || model == CALC_TI82AEP_USB - || ticonv_model_is_tinspire(model)); + || ticonv_model_is_tinspire(model) + || model == CALC_CBL2 + || model == CALC_CBR2 + || model == CALC_LABPRO + || model == CALC_TIPRESENTER); } /** diff --git a/libticalcs/trunk/src/ticalcs.h b/libticalcs/trunk/src/ticalcs.h index 5950b5e0e..54af870dc 100644 --- a/libticalcs/trunk/src/ticalcs.h +++ b/libticalcs/trunk/src/ticalcs.h @@ -167,31 +167,31 @@ typedef enum { FTS_NONE = 0, - OPS_ISREADY = (1 << 0), - OPS_KEYS = (1 << 1), - OPS_SCREEN = (1 << 2), - OPS_DIRLIST = (1 << 3), - OPS_BACKUP = (1 << 4), - OPS_VARS = (1 << 5), - OPS_FLASH = (1 << 6), - OPS_IDLIST = (1 << 7), - OPS_CLOCK = (1 << 8), - OPS_ROMDUMP = (1 << 9), - OPS_VERSION = (1 << 10), - OPS_NEWFLD = (1 << 11), - OPS_DELVAR = (1 << 12), - OPS_OS = (1 << 13), - OPS_RENAME = (1 << 14), - OPS_CHATTR = (1 << 21), - - FTS_SILENT = (1 << 15), - FTS_FOLDER = (1 << 16), - FTS_MEMFREE = (1 << 17), - FTS_FLASH = (1 << 18), - FTS_CERT = (1 << 19), - FTS_BACKUP = (1 << 20), - FTS_NONSILENT = (1 << 22) - + OPS_ISREADY = (1 << 0), + OPS_KEYS = (1 << 1), + OPS_SCREEN = (1 << 2), + OPS_DIRLIST = (1 << 3), + OPS_BACKUP = (1 << 4), + OPS_VARS = (1 << 5), + OPS_FLASH = (1 << 6), + OPS_IDLIST = (1 << 7), + OPS_CLOCK = (1 << 8), + OPS_ROMDUMP = (1 << 9), + OPS_VERSION = (1 << 10), + OPS_NEWFLD = (1 << 11), + OPS_DELVAR = (1 << 12), + OPS_OS = (1 << 13), + OPS_RENAME = (1 << 14), + OPS_CHATTR = (1 << 21), + OPS_LABEQUIPMENTDATA = (1 << 23), + + FTS_SILENT = (1 << 15), + FTS_FOLDER = (1 << 16), + FTS_MEMFREE = (1 << 17), + FTS_FLASH = (1 << 18), + FTS_CERT = (1 << 19), + FTS_BACKUP = (1 << 20), + FTS_NONSILENT = (1 << 22) } CalcFeatures; /** @@ -261,6 +261,7 @@ typedef enum INFOS_COLOR_SCREEN = (1 << 25), INFOS_PYTHON_ON_BOARD = (1 << 26), INFOS_USER_DEFINED_ID = (1 << 27), + // TODO INFOS_PTT_MODE, based on DUSB_PID_PTT_MODE_STATE for the TI-eZ80 series, and whichever NavNet equivalent, if any. // INFOS_MORE_INFOS = (1 << 30), /* Some day ? Reserved value for signaling more bits are available elsewhere */ INFOS_CALC_MODEL = 0x80000000 @@ -303,6 +304,8 @@ typedef enum FNCT_CHATTR, FNCT_SEND_ALL_VARS_BACKUP, FNCT_RECV_ALL_VARS_BACKUP, + FNCT_SEND_LAB_EQUIPMENT_DATA, + FNCT_GET_LAB_EQUIPMENT_DATA, CALC_FNCT_LAST // Keep this one last } CalcFnctsIdx; @@ -566,6 +569,36 @@ typedef struct int state; } CalcClock; +/** + * CalcLabEquipmentDataType: + * + * An enumeration which contains the following data types: + */ +typedef enum +{ + CALC_LAB_EQUIPMENT_DATA_TYPE_NONE = 0, + CALC_LAB_EQUIPMENT_DATA_TYPE_STRING = 1, + CALC_LAB_EQUIPMENT_DATA_TYPE_TI68K_RAW_LIST = 2, + CALC_LAB_EQUIPMENT_DATA_TYPE_TI8586_RAW_LIST = 3, + CALC_LAB_EQUIPMENT_DATA_TYPE_TIZ80_RAW_LIST = 3, +} CalcLabEquipmentDataType; + +/** + * CalcLabEquipmentData: + * @size: size of data to be sent + * @data: pointer to data to be sent + */ +typedef struct +{ + CalcLabEquipmentDataType type; + uint16_t size; + uint16_t items; + const uint8_t * data; + uint16_t index; + uint16_t unknown; + uint8_t vartype; +} CalcLabEquipmentData; + /** * CalcUpdate: * @text: a text to display about the current operation (locale used is those defined by tifiles_transcoding_set) @@ -690,6 +723,8 @@ typedef struct * @change_attr: change attributes of a variable * @send_all_vars_backup: send a fake backup (set of files and FlashApps) * @recv_all_vars_backup: request a fake backup (set of files and FlashApps) + * @send_lab_equipment_data: send data in a format suitable for lab equipment + * @get_lab_equipment_data: get data from a piece of lab equipment * * A structure containing pointers to functions implementing the various operations (potentially) supported by a hand-held. * !!! This structure is for private use !!! @@ -741,6 +776,8 @@ struct _CalcFnctPtrs int (*send_all_vars_backup) (CalcHandle*, FileContent*); int (*recv_all_vars_backup) (CalcHandle*, FileContent*); + int (*send_lab_equipment_data) (CalcHandle*, CalcModel, CalcLabEquipmentData *); + int (*get_lab_equipment_data) (CalcHandle*, CalcModel, CalcLabEquipmentData *); }; /** @@ -864,6 +901,7 @@ typedef struct int attached; int open; CalcFnctsIdx operation; + CalcModel model; union { int intval; @@ -876,6 +914,7 @@ typedef struct NSPRawPacketA nsp_rpkt; NSPVirtualPacket nsp_vpkt; ROMDumpPacket romdump_pkt; + CalcLabEquipmentData labeq_data; struct { void * data; @@ -1059,6 +1098,9 @@ typedef struct TIEXPORT3 int TICALL ticalcs_calc_send_all_vars_backup(CalcHandle *handle, FileContent*); TIEXPORT3 int TICALL ticalcs_calc_recv_all_vars_backup(CalcHandle *handle, FileContent*); + TIEXPORT3 int TICALL ticalcs_calc_send_lab_equipment_data(CalcHandle *handle, CalcModel, CalcLabEquipmentData *); + TIEXPORT3 int TICALL ticalcs_calc_get_lab_equipment_data(CalcHandle *handle, CalcModel, CalcLabEquipmentData *); + TIEXPORT3 int TICALL ticalcs_calc_send_tigroup(CalcHandle *handle, TigContent*, TigMode); TIEXPORT3 int TICALL ticalcs_calc_recv_tigroup(CalcHandle *handle, TigContent*, TigMode); @@ -1080,6 +1122,10 @@ typedef struct TIEXPORT3 int TICALL ticalcs_calc_send_os2(CalcHandle *handle, const char*); + TIEXPORT3 int TICALL ticalcs_calc_send_lab_equipment_data2(CalcHandle *handle, CalcModel, uint8_t, const char *); + TIEXPORT3 int TICALL ticalcs_calc_get_lab_equipment_data2(CalcHandle *handle, CalcModel, uint8_t, const char **); + TIEXPORT3 void TICALL ticalcs_free_lab_equipment_data2(char * data); + TIEXPORT3 int TICALL ticalcs_calc_send_tigroup2(CalcHandle *handle, const char*, TigMode); TIEXPORT3 int TICALL ticalcs_calc_recv_tigroup2(CalcHandle *handle, const char*, TigMode); diff --git a/libticalcs/trunk/src/type2str.cc b/libticalcs/trunk/src/type2str.cc index dd24ac28f..e670bb68c 100644 --- a/libticalcs/trunk/src/type2str.cc +++ b/libticalcs/trunk/src/type2str.cc @@ -156,14 +156,14 @@ int TICALL ticalcs_infos_to_string(CalcInfos *infos, char *str, uint32_t maxlen) char clock_speed[15]; char lcd_width[20]; char lcd_height[20]; - char bpp[14]; + char bpp[20]; char color_screen[11]; - char ram_phys[30]; - char ram_user[30]; - char ram_free[30]; - char flash_phys[30]; - char flash_user[30]; - char flash_free[30]; + char ram_phys[50]; + char ram_user[50]; + char ram_free[50]; + char flash_phys[50]; + char flash_user[50]; + char flash_free[50]; language_ids[0] = 0; if (infos->mask & INFOS_LANG_ID) @@ -314,6 +314,7 @@ int TICALL ticalcs_infos_to_string(CalcInfos *infos, char *str, uint32_t maxlen) (infos->mask & INFOS_BOOT2_VERSION) ? infos->boot2_version : "", (infos->mask & INFOS_OS_VERSION) ? _("OS Version: ") : "", (infos->mask & INFOS_OS_VERSION) ? infos->os_version : "", + (infos->mask & INFOS_RUN_LEVEL) ? _("Run level: ") : "", (infos->mask & INFOS_RUN_LEVEL) ? ((infos->run_level == 2) ? "OS" : "boot") : "", (infos->mask & INFOS_CLOCK_SPEED) ? _("Clock speed: ") : "", diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_get_single_measurement_from_chan1_through_labeqdata.txt b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_get_single_measurement_from_chan1_through_labeqdata.txt new file mode 100644 index 000000000..8f32d6281 --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_get_single_measurement_from_chan1_through_labeqdata.txt @@ -0,0 +1,9 @@ +version 0 +send_lab_equipment_data 8 4 +{0} +send_lab_equipment_data 8 4 +{1,1,1} +send_lab_equipment_data 8 4 +{9,1,0} +get_lab_equipment_data 8 4 +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_play_sound_through_labeqdata.txt b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_play_sound_through_labeqdata.txt new file mode 100644 index 000000000..45f886945 --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_play_sound_through_labeqdata.txt @@ -0,0 +1,4 @@ +version 0 +send_lab_equipment_data 8 4 +{1999,5000,182,5000,162,5000,144,5000,136,5000,121,5000,108,5000,102} +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_off_through_raw.txt b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_off_through_raw.txt new file mode 100644 index 000000000..df11552b4 --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_off_through_raw.txt @@ -0,0 +1,50 @@ +version 0 +raw_send_data +89 06 08 00 0A 00 00 00 04 01 FF 00 0E 01 + +raw_recv_data 4 +raw_recv_data 4 +raw_send_data +89 56 00 00 + +raw_send_data +89 15 0E 00 03 00 00 00 20 31 39 39 38 20 31 20 30 00 9F 01 + +raw_recv_data 4 +raw_send_data +89 92 00 00 + +raw_recv_data 4 +raw_send_data +89 06 08 00 0A 00 00 00 04 01 FF 00 0E 01 + +raw_recv_data 4 +raw_recv_data 4 +raw_send_data +89 56 00 00 + +raw_send_data +89 15 0E 00 03 00 00 00 20 31 39 39 38 20 32 20 30 00 A0 01 + +raw_recv_data 4 +raw_send_data +89 92 00 00 + +raw_recv_data 4 +raw_send_data +89 06 08 00 0A 00 00 00 04 01 FF 00 0E 01 + +raw_recv_data 4 +raw_recv_data 4 +raw_send_data +89 56 00 00 + +raw_send_data +89 15 0E 00 03 00 00 00 20 31 39 39 38 20 33 20 30 00 A1 01 + +raw_recv_data 4 +raw_send_data +89 92 00 00 + +raw_recv_data 4 +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_on_through_dbus.txt b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_on_through_dbus.txt new file mode 100644 index 000000000..8b75c27ee --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_cbl2_set_all_leds_on_through_dbus.txt @@ -0,0 +1,40 @@ +version 0 +dbus_send_pkt 0x89 0x06 8 +0A 00 00 00 04 01 FF 00 + +dbus_recv +dbus_recv_header +dbus_send_pkt 0x89 0x56 0 +dbus_send_pkt 0x89 0x15 14 +03 00 00 00 20 31 39 39 38 20 31 20 31 00 + +dbus_recv_header +dbus_send_pkt 0x89 0x92 0 +dbus_recv_header + +dbus_send_pkt 0x89 0x06 8 +0A 00 00 00 04 01 FF 00 + +dbus_recv_header +dbus_recv +dbus_send_pkt 0x89 0x56 0 +dbus_send_pkt 0x89 0x15 14 +03 00 00 00 20 31 39 39 38 20 32 20 31 00 + +dbus_recv +dbus_send_pkt 0x89 0x92 0 +dbus_recv_header + +dbus_send_pkt 0x89 0x06 8 +0A 00 00 00 04 01 FF 00 + +dbus_recv +dbus_recv +dbus_send_pkt 0x89 0x56 0 +dbus_send_pkt 0x89 0x15 14 +03 00 00 00 20 31 39 39 38 20 33 20 31 00 + +dbus_recv +dbus_send_pkt 0x89 0x92 0 +dbus_recv_header +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_labeq_data_through_labeqdata.txt b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_labeq_data_through_labeqdata.txt new file mode 100644 index 000000000..02a719f7f --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_labeq_data_through_labeqdata.txt @@ -0,0 +1,5 @@ +version 0 +send_lab_equipment_data 8 4 +{7} +get_lab_equipment_data 8 4 +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_list_data_through_raw.txt b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_list_data_through_raw.txt new file mode 100644 index 000000000..1e4d7688c --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_get_list_data_through_raw.txt @@ -0,0 +1,41 @@ +version 0 +raw_send_data +89 06 08 00 03 00 00 00 04 01 FF 00 07 01 + +raw_recv_data 4 +raw_recv_data 4 +raw_send_data +89 56 00 00 + +raw_send_data +89 15 07 00 01 00 00 00 20 37 00 58 00 + +raw_recv_data 4 +raw_send_data +89 92 00 00 + +raw_recv_data 4 +raw_send_data +89 A2 06 00 00 00 00 00 04 00 04 00 + +raw_recv_data 4 +raw_recv_data 4 +buffer_peek_data le16 2 r1 +reg_add 2 r1 +raw_recv_data r1 +buffer_peek_data le32 0 r2 +raw_send_data +89 56 00 00 + +raw_send_data +89 09 00 00 + +raw_recv_data 4 +raw_recv_data 4 +buffer_peek_data le16 2 r1 +reg_add 2 r1 +raw_recv_data r2 +raw_send_data +89 56 00 00 + +exit diff --git a/libticalcs/trunk/tests/input_dbus_ti68k_send_7_through_labeqdata_get_labeq_data_through_dbus.txt b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_through_labeqdata_get_labeq_data_through_dbus.txt new file mode 100644 index 000000000..2809e9d6f --- /dev/null +++ b/libticalcs/trunk/tests/input_dbus_ti68k_send_7_through_labeqdata_get_labeq_data_through_dbus.txt @@ -0,0 +1,19 @@ +version 0 +send_lab_equipment_data 8 4 +{7} +dbus_send_pkt 0x89 0xA2 6 +00 00 00 00 04 00 + +dbus_recv_header +dbus_recv_header +buffer_peek_data le16 2 r1 +dbus_recv_data 0 r1 +buffer_peek_data le32 4 r1 +dbus_send_pkt 0x89 0x56 0 +dbus_send_pkt 0x89 0x09 0 +dbus_recv_header +dbus_recv_header +buffer_peek_data le16 2 r1 +dbus_recv_data 0 r1 +dbus_send_pkt 0x89 0x56 0 +exit diff --git a/libticalcs/trunk/tests/input_dusb_is_ready_through_raw_sendrecv.txt b/libticalcs/trunk/tests/input_dusb_is_ready_through_raw.txt similarity index 60% rename from libticalcs/trunk/tests/input_dusb_is_ready_through_raw_sendrecv.txt rename to libticalcs/trunk/tests/input_dusb_is_ready_through_raw.txt index 816028c73..35cf625c6 100644 --- a/libticalcs/trunk/tests/input_dusb_is_ready_through_raw_sendrecv.txt +++ b/libticalcs/trunk/tests/input_dusb_is_ready_through_raw.txt @@ -1,24 +1,19 @@ +version 0 raw_send_data 00000004 (01) [00000400]  -raw_recv_data -5 -raw_recv_data -4 +raw_recv_data 5 +raw_recv_data 4 raw_send_data 00000010 04 0000000a {0001} 00 03 00 01 00 00 00 00 07 D0  -raw_recv_data -5 -raw_recv_data -2 -raw_recv_data -5 -raw_recv_data -10 +raw_recv_data 5 +raw_recv_data 2 +raw_recv_data 5 +raw_recv_data 10 raw_send_data 00000002 (05) [e000] diff --git a/libticalcs/trunk/tests/test_ticalcs_2.cc b/libticalcs/trunk/tests/test_ticalcs_2.cc index aee065850..98d673cd7 100644 --- a/libticalcs/trunk/tests/test_ticalcs_2.cc +++ b/libticalcs/trunk/tests/test_ticalcs_2.cc @@ -28,12 +28,21 @@ #include #endif +#ifdef HAVE_STRTOK_R +#define STRTOK strtok_r +#elif defined(HAVE_STRTOK_S) +#define STRTOK strtok_s +#else +#error This code needs strtok_r or strtok_s. +#endif + #include #include #include #include #include -#include +#define __STDC_FORMAT_MACROS +#include #include // Happens for some reason on MinGW 64 32-bit GCC 8 toolchain. @@ -46,34 +55,110 @@ #include "../src/ticalcs.h" #include "../src/nsp_cmd.h" #include "../src/cmdz80.h" +#include "../src/cmd68k.h" #include "../src/dusb_rpkt.h" +#include "../src/dusb_cmd.h" #include "../src/keysnsp.h" #include "../src/nsp_rpkt.h" +#include "../src/romdump.h" #include "../src/error.h" #undef VERSION #define VERSION "Test program" -#define scan_print_output(scanformat_, printformat_, output_, print_) \ +#define CURRENT_SCRIPT_VERSION 0 + +// Variables +#define INBUF_DATA_SIZE 262156 +#define INBUF2_DATA_SIZE 2048 +#define PKTDATA_DATA_SIZE 65542 +#define FILENAME_DATA_SIZE 1023 + +static unsigned int version = CURRENT_SCRIPT_VERSION; +static unsigned int cfg_exit_on_failure = 0; +static char inbuf[INBUF_DATA_SIZE + 2]; +static char inbuf2[INBUF2_DATA_SIZE + 2]; +static uint8_t pktdata[2 * PKTDATA_DATA_SIZE]; +static uint8_t pktdata2[PKTDATA_DATA_SIZE]; +static uint32_t pktdata_len = 0; +static uint64_t registers[8+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Utility macros and functions +#define str(s) #s +#define xstr(s) str(s) + +#define scan_print_output_1(input_, scanformat_, printformat_, output1_, print1_) \ +({ \ + int ret__ = 0; \ + if (NULL != input_ && input_[0] != 0) \ + { \ + ret__ = sscanf(input_, scanformat_, output1_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_); \ + } \ + } \ + if (ret__ < 1) \ + { \ + ret__ = scanf(scanformat_, output1_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_); \ + } \ + } \ + ret__; \ +}) + +#define scan_print_output_2(input_, scanformat_, printformat_, output1_, output2_, print1_, print2_) \ ({ \ - int ret__ = scanf(scanformat_, output_); \ - if (!isatty(0)) \ + int ret__ = 0; \ + if (NULL != input_ && input_[0] != 0) \ + { \ + ret__ = sscanf(input_, scanformat_, output1_, output2_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_, print2_); \ + } \ + } \ + if (ret__ < 1) \ { \ - printf(printformat_ "\n", print_); \ + ret__ = scanf(scanformat_, output1_, output2_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_, print2_); \ + } \ } \ ret__; \ }) -#define FILENAME_DATA_SIZE 1023 -#define str(s) #s -#define xstr(s) str(s) +#define scan_print_output_3(input_, scanformat_, printformat_, output1_, output2_, output3_, print1_, print2_, print3_) \ +({ \ + int ret__ = 0; \ + if (NULL != input_ && input_[0] != 0) \ + { \ + ret__ = sscanf(input_, scanformat_, output1_, output2_, output3_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_, print2_, print3_); \ + } \ + } \ + if (ret__ < 1) \ + { \ + ret__ = scanf(scanformat_, output1_, output2_, output3_); \ + if (!isatty(0)) \ + { \ + printf(printformat_ "\n", print1_, print2_, print3_); \ + } \ + } \ + ret__; \ +}) static int read_filename(char * filename, const char * message) { int ret; filename[0] = 0; printf("Enter filename%s: ", message); - ret = scan_print_output("%" xstr(FILENAME_DATA_SIZE) "s", "%s", filename, filename); + ret = scan_print_output_1("", "%" xstr(FILENAME_DATA_SIZE) "s", "%s", filename, filename); return ret; } @@ -81,7 +166,7 @@ static int read_varname(CalcHandle* h, VarRequest *vr, const char *prompt) { char buf[256]; const char *s; - int ret = 1; + int ret = 0; char * endptr; memset(vr, 0, sizeof(VarRequest)); @@ -89,39 +174,47 @@ static int read_varname(CalcHandle* h, VarRequest *vr, const char *prompt) if (ticalcs_calc_features(h) & FTS_FOLDER) { printf("Enter%s folder name: ", prompt); - ret = scan_print_output("%1023s", "%s", vr->folder, vr->folder); + ret = scan_print_output_1("", "%" xstr(FILENAME_DATA_SIZE) "s", "%s", vr->folder, vr->folder); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + return 1; + } } - if (ret >= 1) + printf("Enter%s variable name: ", prompt); + ret = scan_print_output_1("", "%" xstr(FILENAME_DATA_SIZE) "s", "%s", vr->name, vr->name); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + return 1; + } + + ret = 0; + if (ticonv_model_is_tiz80(h->model) || ticonv_model_is_tiez80(h->model)) { - printf("Enter%s variable name: ", prompt); - ret = scan_print_output("%1023s", "%s", vr->name, vr->name); - if (ret >= 1) + printf("Enter%s variable type: ", prompt); + ret = scan_print_output_1("", "%255s", "%s", buf, buf); + if (ret < 1) { - if (ticonv_model_is_tiz80(h->model) || ticonv_model_is_tiez80(h->model)) - { - printf("Enter%s variable type: ", prompt); - ret = scan_print_output("%255s", "%s", buf, buf); - if (ret < 1) - { - return 0; - } + fputs("Missing parameters\n", stderr); + return 1; + } - // Special handling for types written in hex. - errno = 0; - vr->type = (uint8_t)strtoul(buf, &endptr, 16); + ret = 0; + // Special handling for types written in hex. + errno = 0; + vr->type = (uint8_t)strtoul(buf, &endptr, 16); - if (errno != 0) - { - // The string doesn't seem to be a valid numeric value. - // Let's try to parse a fext instead. - vr->type = tifiles_fext2vartype(h->model, buf); - s = tifiles_vartype2string(h->model, vr->type); - if (s == NULL || *s == 0) - { - vr->type = tifiles_string2vartype(h->model, buf); - } - } + if (errno != 0) + { + // The string doesn't seem to be a valid numeric value. + // Let's try to parse a fext instead. + vr->type = tifiles_fext2vartype(h->model, buf); + s = tifiles_vartype2string(h->model, vr->type); + if (s == NULL || *s == 0) + { + vr->type = tifiles_string2vartype(h->model, buf); } } } @@ -131,6 +224,7 @@ static int read_varname(CalcHandle* h, VarRequest *vr, const char *prompt) static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, unsigned char * data, uint32_t maxdatalen, uint32_t * length) { + int ret = 1; uint32_t i; uint8_t c = 0; int odd = 0; @@ -138,11 +232,16 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un { if (buffer[i] == 0) { + //printf("Remaining \"%02X\"\n", c); if (odd) { puts("Odd number of nibbles in hex string, bailing out"); } - return odd; + else + { + ret = 0; + } + break; } else if (buffer[i] >= '0' && buffer[i] <= '9') { @@ -164,6 +263,7 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un { if (*length < maxdatalen) { + //printf("Serializing \"%02X\"\n", c); *data++ = c; odd = 0; c = 0; @@ -171,7 +271,8 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un else { printf("Reached max length of %lu bytes, bailing out\n", (unsigned long)maxdatalen); - return 0; + ret = 0; + break; } (*length)++; } @@ -181,7 +282,8 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un c <<= 4; } } - return 1; + + return ret; } #define get_hex_input(buffer, bufferlen, data, datalen, outlength, message, maxstrlen) \ @@ -190,7 +292,7 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un \ buffer[0] = 0; \ printf("Enter %s as hex string of up to %s bytes (non-hex characters ignored; CTRL+D to end):\n", message, maxstrlen); \ - ret_ = scan_print_output("%" maxstrlen "[^\x04]", "%s", buffer, buffer); \ + ret_ = scan_print_output_1("", "%" maxstrlen "[^\x04]", "%s", buffer, buffer); \ if (ret_ >= 1) \ { \ if (fgetc(stdin) == EOF) {} /* Swallow a single Ctrl+D. */ \ @@ -207,610 +309,1453 @@ static int build_raw_bytes_from_hex_string(char * buffer, uint32_t maxbuflen, un ret_ = 1; \ } \ } \ + else \ + { \ + *outlength = 0; \ + } \ \ ret_; \ }) -static void print_lc_error(int errnum) +static int check_regno(unsigned int regno) { - char *msg = NULL; - - ticables_error_get(errnum, &msg); - fprintf(stderr, "Link cable error (code %i)...\n<<%s>>\n", errnum, msg); - ticables_error_free(msg); + if (!regno || regno >= (int)(sizeof(registers) / sizeof(registers[0]))) + { + fputs("Invalid register number\n", stderr); + return 1; + } + return 0; } -typedef int (*FNCT_MENU) (CalcHandle*); - -static int is_ready(CalcHandle* h) +static int parse_access_type(const char * datatype, unsigned int * endianness, unsigned int * bytes) { - int ret; + if (datatype[0] == 'l' && datatype[1] == 'e') + { + *endianness = 0; + } + else if (datatype[0] == 'b' && datatype[1] == 'e') + { + *endianness = 1; + } + else + { + fputs("Unknown endianness\n", stderr); + return 1; + } - ret = ticalcs_calc_isready(h); - printf("Hand-held is %sready !\n", ret ? "not " : ""); + if (datatype[2] == '0' && datatype[3] == '8') + { + *bytes = 1; + } + else if (datatype[2] == '1' && datatype[3] == '6') + { + *bytes = 2; + } + else if (datatype[2] == '3' && datatype[3] == '2') + { + *bytes = 4; + } + else if (datatype[2] == '6' && datatype[3] == '4') + { + *bytes = 8; + } + else + { + fputs("Unknown size\n", stderr); + return 1; + } - return ret; + return 0; } -static int send_key(CalcHandle *h) +static int parse_check_uint32(const char * input, uint32_t * val, uint32_t maxval) { int ret; - unsigned int key_value; + unsigned int regno; - printf("Enter key value to be sent: "); - ret = scan_print_output("%u", "%u", &key_value, key_value); + if (nullptr == input) + { + return 1; + } + ret = sscanf(input, "r%u", ®no); if (ret < 1) { - return 0; + ret = !sscanf(input, "%" SCNi32, val); + /*if (!ret) + { + printf("Found valid value %" PRIu32, *val); + }*/ + } + else + { + ret = check_regno(regno); + if (!ret) + { + //printf("Found valid register %u\n", regno); + *val = (uint32_t)registers[regno]; + } } - return ticalcs_calc_send_key(h, key_value); -} - -static int execute(CalcHandle *h) -{ - VarEntry ve; + if (!ret) + { + if (*val >= maxval) + { + fputs("Value too large\n", stderr); + ret = 1; + } + } - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) + if (!ret) + { + printf("Valid value is %" PRIx32 " (%" PRIu32 ")\n", *val, *val); + } + else { - return 0; + fputs("Invalid value\n", stderr); } - return ticalcs_calc_execute(h, &ve, ""); + return ret; } -static int recv_screen(CalcHandle *h) +static int parse_check_uint64(const char * input, uint64_t * val) { - CalcInfos infos; int ret; + unsigned int regno; - memset((void *)&infos, 0, sizeof(infos)); - ret = ticalcs_calc_get_version(h, &infos); - if (!ret) + if (nullptr == input) { - CalcScreenCoord sc = { SCREEN_CLIPPED, 0, 0, 0, 0, CALC_PIXFMT_MONO }; - if (infos.bits_per_pixel == 1) - { - // Do nothing, sc already contains CALC_PIXFMT_MONO; - } - else if (infos.bits_per_pixel == 4) - { - sc.pixel_format = CALC_PIXFMT_GRAY_4; - } - else if (infos.bits_per_pixel == 16) - { - sc.pixel_format = CALC_PIXFMT_RGB_565_LE; - } - else + return 1; + } + ret = sscanf(input, "r%u", ®no); + if (ret < 1) + { + ret = !sscanf(input, "%" SCNi64, val); + /*if (!ret) { - fprintf(stderr, "Unsupported bpp depth\n"); - ret = 1; - } + printf("Found valid value %" PRIu64, *val); + }*/ + } + else + { + ret = check_regno(regno); if (!ret) { - uint8_t* bitmap = NULL; - ret = ticalcs_calc_recv_screen_rgb888(h, &sc, &bitmap); - if (!ret) - { - char filename[FILENAME_DATA_SIZE + 7]; - ret = read_filename(filename, " for outputting raw RGB888 pixels"); - if (ret >= 1) - { - ret = 1; - FILE * f = fopen(filename, "w+b"); - if (NULL != f) - { - unsigned int count = sc.width * sc.height * 3; - if (count > fwrite((void *)bitmap, 1, sc.width * sc.height * 3, f)) - { - fprintf(stderr, "Error writing bitmap data\n"); - } - else - { - ret = 0; - } - fclose(f); - } - } - ticalcs_free_screen(bitmap); - } + //printf("Found valid register %u\n", regno); + *val = registers[regno]; } } - return ret; -} - -static int get_dirlist(CalcHandle *h) -{ - GNode *vars, *apps; - int ret; - ret = ticalcs_calc_get_dirlist(h, &vars, &apps); if (!ret) { - ticalcs_dirlist_display(vars); - ticalcs_dirlist_display(apps); - ticalcs_dirlist_destroy(&vars); - ticalcs_dirlist_destroy(&apps); + printf("Valid value is %" PRIx64 " (%" PRIu64 ")\n", *val, *val); + } + else + { + fputs("Invalid value\n", stderr); } return ret; } -static int get_memfree(CalcHandle *h) +static int parse_check_register(const char * input, unsigned int * regno) { - uint32_t ram, flash; int ret; - ret = ticalcs_calc_get_memfree(h, &ram, &flash); + *regno = 0; + ret = sscanf(input, "r%u", regno); + if (ret == 1) + { + ret = check_regno(*regno); + } + else + { + fputs("Missing register\n", stderr); + ret = 1; + } + if (!ret) { - printf("RAM: %lu\tFlash: %lu\n", (unsigned long)ram, (unsigned long)flash); + printf("Valid register is r%u", *regno); } return ret; } -static int send_backup(CalcHandle* h) +static int parse_reg_commands_args(char * input, uint64_t * val, uint32_t * regno) { - char filename[FILENAME_DATA_SIZE + 1]; - char filename2[FILENAME_DATA_SIZE + 11]; int ret; + char * token; + char * saveptr = NULL; - ret = read_filename(filename, ""); - if (ret >= 1) + token = STRTOK(input, " ", &saveptr); + if (NULL == token) { - snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_backup(h->model)); - filename2[sizeof(filename2) - 1] = 0; - - return ticalcs_calc_send_backup2(h, filename); + fputs("Missing parameter 1\n", stderr); + return 1; } - return ret; -} -static int recv_backup(CalcHandle* h) -{ - char filename[FILENAME_DATA_SIZE + 1]; - char filename2[FILENAME_DATA_SIZE + 11]; - int ret; + ret = parse_check_uint64(token, val); + if (ret) return 1; - ret = read_filename(filename, " for backup"); - if (ret < 1) + token = STRTOK(NULL, " ", &saveptr); + if (NULL == token) { - snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_backup(h->model)); - filename2[sizeof(filename2) - 1] = 0; - - return ticalcs_calc_recv_backup2(h, filename); + fputs("Missing parameter 2\n", stderr); + return 1; } + + ret = parse_check_register(token, regno); + if (ret) return 1; + + puts("Good"); return ret; } -static int send_var(CalcHandle* h) +static void hexdump(uint8_t * ptr, uint32_t length) { - char filename[FILENAME_DATA_SIZE + 1]; - int ret; - FileContent *content; - VarEntry ve; - - ret = read_filename(filename, " for variable"); - if (ret >= 1) + fputs("\n\t", stdout); + for (uint32_t i = 0; i < length;) { - if (h->model == CALC_NSPIRE) - { - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) - { - return 0; - } - } - - content = tifiles_content_create_regular(h->model); - if (content != NULL) - { - ret = tifiles_file_read_regular(filename, content); - if (!ret) - { - if (h->model == CALC_NSPIRE) - { - strncpy(content->entries[0]->folder, ve.folder, sizeof(content->entries[0]->folder) - 1); - content->entries[0]->folder[sizeof(content->entries[0]->folder) - 1] = 0; - strncpy(content->entries[0]->name, ve.name, sizeof(content->entries[0]->name) - 1); - content->entries[0]->name[sizeof(content->entries[0]->name) - 1] = 0; - } - ret = ticalcs_calc_send_var(h, MODE_NORMAL, content); - tifiles_content_delete_regular(content); - } - } - else + printf("%02X ", *ptr++); + if (!(++i & 15)) { - ret = ERR_MALLOC; + fputs("\n\t", stdout); } } - return ret; + putchar('\n'); } -static int recv_var(CalcHandle* h) +static void print_lc_error(int errnum) { - char filename[FILENAME_DATA_SIZE + 1]; - int ret; - VarEntry ve; + char *msg = NULL; - ret = read_filename(filename, " for variable"); - if (ret >= 1) - { - memset(&ve, 0, sizeof(ve)); + ticables_error_get(errnum, &msg); + fprintf(stderr, "Link cable error (code %i)...\n<<%s>>\n", errnum, msg); + ticables_error_free(msg); +} + + +// Worker functions +typedef int (*FNCT_MENU) (CalcHandle*, int, char *); + +static int cfg_get(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int cfg_set(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int sleep(CalcHandle * h, int, char * input) +{ + int ret; + unsigned int delay; + + printf("Enter delay in tenths of seconds: "); + ret = scan_print_output_1(input, "%u", "%u", &delay, delay); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + return 1; + } + ret = 0; + + if (delay >= 10) + { + sleep(delay / 10); + } + delay %= 10; + if (delay != 0) + { + usleep(100000 * delay); + } + + return ret; +} + +static int timeout(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int delay(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int probe_calc(CalcHandle * h, int, char * input) +{ + int m = 0; + int p = 0; + int ret; + CalcModel model = CALC_NONE; + + printf("Enter cable & port for probing (c p): "); + ret = scan_print_output_2(input, "%d %d", "%d %d", &m, &p, m, p); + if (ret < 2) + { + fputs("Missing parameters\n", stderr); + return 1; + } + + ret = ticalcs_probe((CableModel)m, (CablePort)p, &model, !0); + //ticalcs_probe_calc(h->cable, &model); + //ticalcs_probe_usb_calcs(h->cable, &model); + printf("Found: <%s>\n", ticalcs_model_to_string(model)); + + return ret; +} + +static int is_ready(CalcHandle * h, int, char *) +{ + int ret; + + ret = ticalcs_calc_isready(h); + printf("%d Hand-held is %sready !\n", ret, ret ? "not " : ""); + + return ret; +} + +static int send_key(CalcHandle * h, int, char * input) +{ + int ret; + unsigned int key_value; + + printf("Enter key value to be sent: "); + ret = scan_print_output_1(input, "%u", "%u", &key_value, key_value); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + return 1; + } + + return ticalcs_calc_send_key(h, key_value); +} + +static int execute(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry ve; + + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_execute(h, &ve, ""); + } + + return ret; +} + +static int recv_screen(CalcHandle * h, int, char *) +{ + int ret; + CalcInfos infos; + + memset((void *)&infos, 0, sizeof(infos)); + ret = ticalcs_calc_get_version(h, &infos); + if (!ret) + { + CalcScreenCoord sc = { SCREEN_CLIPPED, 0, 0, 0, 0, CALC_PIXFMT_MONO }; + if (infos.bits_per_pixel == 1) + { + // Do nothing, sc already contains CALC_PIXFMT_MONO. + } + else if (infos.bits_per_pixel == 4) + { + sc.pixel_format = CALC_PIXFMT_GRAY_4; + } + else if (infos.bits_per_pixel == 16) + { + sc.pixel_format = CALC_PIXFMT_RGB_565_LE; + } + else + { + fprintf(stderr, "Unsupported bpp depth\n"); + ret = 1; + } + if (!ret) + { + uint8_t* bitmap = NULL; + ret = ticalcs_calc_recv_screen_rgb888(h, &sc, &bitmap); + if (!ret) + { + char filename[FILENAME_DATA_SIZE + 7]; + ret = read_filename(filename, " for outputting raw RGB888 pixels"); + if (ret < 1) + { + ret = 1; + } + else + { + ret = 1; + FILE * f = fopen(filename, "w+b"); + if (NULL != f) + { + unsigned int count = sc.width * sc.height * 3; + if (count > fwrite((void *)bitmap, 1, sc.width * sc.height * 3, f)) + { + fprintf(stderr, "Error writing bitmap data\n"); + } + else + { + ret = 0; + } + fclose(f); + } + } + ticalcs_free_screen(bitmap); + } + } + } + + return ret; +} + +static int get_dirlist(CalcHandle * h, int, char *) +{ + int ret; + GNode *vars, *apps; + + ret = ticalcs_calc_get_dirlist(h, &vars, &apps); + if (!ret) + { + ticalcs_dirlist_display(vars); + ticalcs_dirlist_display(apps); + ticalcs_dirlist_destroy(&vars); + ticalcs_dirlist_destroy(&apps); + } + + return ret; +} + +static int get_memfree(CalcHandle * h, int, char *) +{ + int ret; + uint32_t ram, flash; + + ret = ticalcs_calc_get_memfree(h, &ram, &flash); + if (!ret) + { + printf("RAM: %lu\tFlash: %lu\n", (unsigned long)ram, (unsigned long)flash); + } + + return ret; +} + +static int send_backup(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + char filename2[FILENAME_DATA_SIZE + 11]; + + ret = read_filename(filename, ""); + if (ret < 1) + { + return 1; + } + + snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_backup(h->model)); + filename2[sizeof(filename2) - 1] = 0; + + ret = ticalcs_calc_send_backup2(h, filename); + + return ret; +} + +static int recv_backup(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + char filename2[FILENAME_DATA_SIZE + 11]; + + ret = read_filename(filename, " for backup"); + if (ret < 1) + { + return 1; + } + + snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_backup(h->model)); + filename2[sizeof(filename2) - 1] = 0; + + ret = ticalcs_calc_recv_backup2(h, filename); + + return ret; +} + +static int send_var(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + FileContent *content; + VarEntry ve; + + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = 0; + if (h->model == CALC_NSPIRE) + { + memset(&ve, 0, sizeof(ve)); if (!read_varname(h, &ve, "")) { - return 0; + return 1; } + } + + content = tifiles_content_create_regular(h->model); + if (content != NULL) + { + ret = tifiles_file_read_regular(filename, content); + if (!ret) + { + if (h->model == CALC_NSPIRE) + { + strncpy(content->entries[0]->folder, ve.folder, sizeof(content->entries[0]->folder) - 1); + content->entries[0]->folder[sizeof(content->entries[0]->folder) - 1] = 0; + strncpy(content->entries[0]->name, ve.name, sizeof(content->entries[0]->name) - 1); + content->entries[0]->name[sizeof(content->entries[0]->name) - 1] = 0; + } + ret = ticalcs_calc_send_var(h, MODE_NORMAL, content); + tifiles_content_delete_regular(content); + } + } + else + { + ret = ERR_MALLOC; + } + + return ret; +} + +static int recv_var(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + VarEntry ve; + + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = 1; + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_recv_var2(h, MODE_NORMAL, filename, &ve); + } + + return ret; +} + +static int send_var_ns(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = ticalcs_calc_send_var_ns2(h, MODE_NORMAL, filename); + + return ret; +} + +static int recv_var_ns(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + VarRequest *ve; + + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = ticalcs_calc_recv_var_ns2(h, MODE_NORMAL, filename, &ve); + + return ret; +} + +static int send_app(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + char filename2[FILENAME_DATA_SIZE + 11]; + + ret = read_filename(filename, " for app"); + if (ret < 1) + { + return 1; + } + + snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_flash_app(h->model)); + filename2[sizeof(filename2) - 1] = 0; + + ret = ticalcs_calc_send_app2(h, filename); + + return ret; +} + +static int recv_app(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + VarEntry ve; + + ret = read_filename(filename, " for app"); + if (ret < 1) + { + return 1; + } + + memset(&ve, 0, sizeof(ve)); + printf("Enter application name: "); + ret = scan_print_output_1("", "%" xstr(FILENAME_DATA_SIZE) "s", "%s", ve.name, ve.name); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + ret = 1; + } + else + { + ret = ticalcs_calc_recv_app2(h, filename, &ve); + } + + return ret; +} - return ticalcs_calc_recv_var2(h, MODE_NORMAL, filename, &ve); +static int send_os(CalcHandle * h, int, char *) +{ + int ret; + char filename[FILENAME_DATA_SIZE + 1]; + + ret = read_filename(filename, " for OS"); + if (ret < 1) + { + return 1; } + + ret = ticalcs_calc_send_os2(h, filename); + return ret; } -static int send_var_ns(CalcHandle* h) +static int recv_idlist(CalcHandle * h, int, char *) { - char filename[FILENAME_DATA_SIZE + 1]; int ret; + uint8_t id[32]; - ret = read_filename(filename, " for variable"); - if (ret >= 1) + ret = ticalcs_calc_recv_idlist(h, id); + if (!ret) { - return ticalcs_calc_send_var_ns2(h, MODE_NORMAL, filename); + printf("IDLIST: <%s>\n", id); } + return ret; } -static int recv_var_ns(CalcHandle* h) +static int dump_rom(CalcHandle * h, int, char *) { + int ret; char filename[FILENAME_DATA_SIZE + 1]; + + ret = read_filename(filename, " for ROM / Flash dump"); + if (ret < 1) + { + return 1; + } + + ret = ticalcs_calc_dump_rom_1(h); + if (!ret) + { + ret = ticalcs_calc_dump_rom_2(h, ROMSIZE_AUTO, filename); + } + + return ret; +} + +static int set_clock(CalcHandle * h, int, char *) +{ int ret; - VarRequest *ve; + CalcClock clk; - ret = read_filename(filename, " for variable"); - if (ret >= 1) + ret = ticalcs_calc_get_clock(h, &clk); + if (!ret) { - return ticalcs_calc_recv_var_ns2(h, MODE_NORMAL, filename, &ve); + ret = ticalcs_calc_set_clock(h, &clk); } + return ret; } -static int send_app(CalcHandle *h) +static int get_clock(CalcHandle * h, int, char *) { - char filename[FILENAME_DATA_SIZE + 1]; - char filename2[FILENAME_DATA_SIZE + 11]; int ret; + CalcClock clk; - ret = read_filename(filename, " for app"); - if (ret >= 1) + ret = ticalcs_calc_get_clock(h, &clk); + if (!ret) { - snprintf(filename2, sizeof(filename2) - 1, "%s.%s", filename, tifiles_fext_of_flash_app(h->model)); - filename2[sizeof(filename2) - 1] = 0; + ticalcs_clock_show(h->model, &clk); + } + + return ret; +} + +static int del_var(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry ve; - return ticalcs_calc_send_app2(h, filename); + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_del_var(h, &ve); } + return ret; } -static int recv_app(CalcHandle *h) +static int new_folder(CalcHandle * h, int, char *) { - char filename[FILENAME_DATA_SIZE + 1]; - int ret; + int ret = 1; VarEntry ve; - ret = read_filename(filename, " for app"); - if (ret >= 1) + memset(&ve, 0, sizeof(ve)); + if (!ticonv_model_is_tiz80(h->model) && !ticonv_model_is_tiez80(h->model)) { - memset(&ve, 0, sizeof(ve)); - printf("Enter application name: "); - ret = scan_print_output("%1023s", "%s", ve.name, ve.name); - if (ret >= 1) + printf("Enter folder name: "); + ret = scan_print_output_1("", "%" xstr(FILENAME_DATA_SIZE) "s", "%s", ve.folder, ve.folder); + if (ret < 1) + { + fputs("Missing parameters\n", stderr); + ret = 1; + } + else { - return ticalcs_calc_recv_app2(h, filename, &ve); + ret = ticalcs_calc_new_fld(h, &ve); } } + return ret; } -static int send_os(CalcHandle *h) +static int get_version(CalcHandle * h, int, char *) { - char filename[FILENAME_DATA_SIZE + 1]; int ret; + CalcInfos infos; + char str[2048]; - ret = read_filename(filename, " for OS"); - if (ret >= 1) + memset((void *)&infos, 0, sizeof(infos)); + ret = ticalcs_calc_get_version(h, &infos); + if (!ret) { - return ticalcs_calc_send_os2(h, filename); + str[0] = 0; + ret = ticalcs_infos_to_string(&infos, str, sizeof(str)); + if (!ret) + { + puts(str); + } } + return ret; } -static int recv_idlist(CalcHandle *h) +static int send_cert(CalcHandle * h, int, char *) { - uint8_t id[32]; - int ret; + int ret = -1; - ret = ticalcs_calc_recv_idlist(h, id); - if (!ret) + fputs("Not implemented\n", stderr); + + return ret; +} + +static int recv_cert(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int rename_var(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry src; + VarEntry dst; + + memset(&src, 0, sizeof(src)); + if (read_varname(h, &src, " current")) { - printf("IDLIST: <%s>\n", id); + memset(&dst, 0, sizeof(dst)); + if (read_varname(h, &dst, " new")) + { + ret = ticalcs_calc_rename_var(h, &src, &dst); + } } return ret; } -static int dump_rom(CalcHandle *h) +static int archive_var(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry ve; + + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_change_attr(h, &ve, ATTRB_ARCHIVED); + } + + return ret; +} + +static int unarchive_var(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry ve; + + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_change_attr(h, &ve, ATTRB_NONE); + } + + return ret; +} + +static int lock_var(CalcHandle * h, int, char *) +{ + int ret = 1; + VarEntry ve; + + memset(&ve, 0, sizeof(ve)); + if (read_varname(h, &ve, "")) + { + ret = ticalcs_calc_change_attr(h, &ve, ATTRB_LOCKED); + } + + return ret; +} + +static int send_all_vars_backup(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int recv_all_vars_backup(CalcHandle * h, int, char *) +{ + int ret = -1; + + fputs("Not implemented\n", stderr); + + return ret; +} + +static int send_lab_equipment_data(CalcHandle * h, int, char * input) { - char filename[FILENAME_DATA_SIZE + 1]; int ret; + const uint8_t * ptr; + uint8_t * orig_ptr; + CalcLabEquipmentData lab_equipment_data; + int model; + unsigned int vartype; - ret = read_filename(filename, " for ROM / Flash dump"); - if (ret >= 1) + printf("Enter calc model (usually 1-12, 16-17) and variable type (4 for lists): "); + ret = scan_print_output_2(input, "%d %u", "%d %u", &model, &vartype, model, vartype); + if (ret < 2) { - ret = ticalcs_calc_dump_rom_1(h); - if (!ret) - { - ret = ticalcs_calc_dump_rom_2(h, ROMSIZE_AUTO, filename); - } + fputs("Missing parameters\n", stderr); + return 1; + } + + if (vartype != 4) + { + fputs("Variable type not supported for now\n", stderr); + return 1; + } + + printf("Enter list data as '{...}': \n"); + orig_ptr = (uint8_t *)inbuf + 1024 + 4; + ptr = (const uint8_t *)fgets((char *)orig_ptr, 1024, stdin); + + ret = 1; + if (NULL != ptr) + { + lab_equipment_data.type = CALC_LAB_EQUIPMENT_DATA_TYPE_STRING; + lab_equipment_data.size = strlen((const char *)ptr) + 1; + lab_equipment_data.items = 0; + lab_equipment_data.data = ptr; + lab_equipment_data.vartype = (uint8_t)vartype; + ret = ticalcs_calc_send_lab_equipment_data(h, (CalcModel)model, &lab_equipment_data); } + // else do nothing, we already set ret = 1 above. + return ret; } -static int set_clock(CalcHandle *h) +static int get_lab_equipment_data(CalcHandle * h, int, char * input) { - CalcClock clk; int ret; + CalcLabEquipmentData lab_equipment_data; + int model; + unsigned int vartype; + + printf("Enter calc model (usually 1-12, 16-17) and variable type (4 for lists): "); + ret = scan_print_output_2(input, "%d %u", "%d %u", &model, &vartype, model, vartype); + if (ret < 2) + { + fputs("Missing parameters\n", stderr); + return 1; + } + + if (vartype != 4) + { + fputs("Variable type not supported for now\n", stderr); + return 1; + } + + memset((void *)&lab_equipment_data, 0, sizeof(lab_equipment_data)); + lab_equipment_data.vartype = (uint8_t)vartype; + ret = ticalcs_calc_get_lab_equipment_data(h, (CalcModel)model, &lab_equipment_data); - ret = ticalcs_calc_get_clock(h, &clk); if (!ret) { - ret = ticalcs_calc_set_clock(h, &clk); + printf("Received list data type %d size %" PRIu16 " vartype %" PRIu8 " items %" PRIu16 "\n", lab_equipment_data.type, lab_equipment_data.size, lab_equipment_data.vartype, lab_equipment_data.items); + const uint8_t * ptr = lab_equipment_data.data; + for (uint16_t i = 0; i < lab_equipment_data.size; i++) + { + printf("%02X ", ptr[i]); + } + putchar('\n'); } + while (0); return ret; } -static int get_clock(CalcHandle *h) +static int buffer_set_data(CalcHandle * h, int, char * input) { - CalcClock clk; int ret; + uint32_t offset = 0; + uint32_t length = 0; - ret = ticalcs_calc_get_clock(h, &clk); + printf("Enter offset: "); + ret = parse_check_uint32(input, &offset, sizeof(pktdata) / 2); + if (ret) return 1; + + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata + offset, sizeof(pktdata) / 2, &length, "raw data", xstr(INBUF_DATA_SIZE)); if (!ret) { - ticalcs_clock_show(h->model, &clk); + pktdata_len = offset + length; } return ret; } -static int del_var(CalcHandle* h) +static int buffer_get_data(CalcHandle * h, int, char * input) { - VarEntry ve; + int ret = 0; + uint32_t length = pktdata_len; + uint32_t offset = 0; + char * token; + char * saveptr = NULL; - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) + printf("Enter nothing, offset, or offset and length: "); + token = STRTOK(input, " ", &saveptr); + if (NULL != token) + { + // There's at least an offset. + ret = parse_check_uint32(token, &offset, sizeof(pktdata)); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL != token) + { + // There's also a length. + ret = parse_check_uint32(token, &length, sizeof(pktdata)); + if (ret) return 1; + } + // else do nothing, length was already initialized. + } + // else do nothing, offset and length were already initialized. + + if (offset + length >= sizeof(pktdata)) { - return 0; + fputs("Offset + length is too large\n", stderr); + return 1; } - return ticalcs_calc_del_var(h, &ve); + ret = 0; + hexdump(pktdata + offset, length); + + return ret; } -static int new_folder(CalcHandle* h) +static int buffer_peek_data(CalcHandle * h, int, char * input) { - VarEntry ve; int ret; + unsigned int endianness; + unsigned int bytes; + uint32_t offset; + unsigned int regno; + uint64_t val; + char * token; + char * saveptr = NULL; - memset(&ve, 0, sizeof(ve)); - if (!ticonv_model_is_tiz80(h->model) && !ticonv_model_is_tiez80(h->model)) + if (!pktdata_len) { - printf("Enter folder name: "); - ret = scan_print_output("%1023s", "%s", ve.folder, ve.folder); - if (ret < 1) + fputs("No packet data is available, skipping\n", stderr); + return 1; + } + + // Parse input to retrieve access type (e.g. le32), offset, destination register. + token = STRTOK(input, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 1\n", stderr); + return 1; + } + + ret = parse_access_type(token, &endianness, &bytes); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 2\n", stderr); + return 1; + } + + ret = parse_check_uint32(token, &offset, sizeof(pktdata) - bytes); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 3\n", stderr); + return 1; + } + + ret = parse_check_register(token, ®no); + if (ret) return 1; + + puts("Good"); + + val = 0; + if (!endianness) + { + // Read LE: MSB are stored last. + uint8_t * ptr = pktdata + offset + bytes; + for (unsigned int i = 0; i < bytes; i++) + { + val |= *--ptr; + if (i != bytes - 1) + { + val <<= 8; + } + } + } + else + { + // Read BE: MSB are stored first. + uint8_t * ptr = pktdata + offset; + for (unsigned int i = 0; i < bytes; i++) { - return 0; + val |= *ptr++; + if (i != bytes - 1) + { + val <<= 8; + } } } + printf("val: %" PRIu64 " / %16" PRIx64 "\n", val, val); + registers[regno] = val; - return ticalcs_calc_new_fld(h, &ve); + return ret; } -static int get_version(CalcHandle *h) +static int buffer_poke_data(CalcHandle * h, int, char * input) { int ret; - CalcInfos infos; - char str[2048]; + uint32_t offset; + unsigned int endianness; + unsigned int bytes; + uint64_t val; + char * token; + char * saveptr = NULL; - memset((void *)&infos, 0, sizeof(infos)); - ret = ticalcs_calc_get_version(h, &infos); - if (!ret) + // Parse input to retrieve access type (e.g. le32), offset, destination register. + token = STRTOK(input, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 1\n", stderr); + return 1; + } + + ret = parse_access_type(token, &endianness, &bytes); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 2\n", stderr); + return 1; + } + + ret = parse_check_uint32(token, &offset, sizeof(pktdata) - bytes); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL == token) + { + fputs("Missing parameter 3\n", stderr); + return 1; + } + + ret = parse_check_uint64(token, &val); + if (ret) return 1; + + puts("Good"); + + printf("val: %" PRIu64 " / %16" PRIx64 "\n", val, val); + + if (!endianness) + { + // Write LE: MSB are stored last. + uint8_t * ptr = pktdata + offset; + for (unsigned int i = 0; i < bytes; i++) + { + *ptr++ = (uint8_t)(val & 0xFF); + val >>= 8; + } + } + else { - str[0] = 0; - ret = ticalcs_infos_to_string(&infos, str, sizeof(str)); - if (!ret) + // Write BE: MSB are stored first. + uint8_t * ptr = pktdata + offset + bytes; + for (unsigned int i = 0; i < bytes; i++) { - puts(str); + *--ptr = (uint8_t)(val & 0xFF); + val >>= 8; } } + // Update buffer size. + if (offset > pktdata_len) + { + pktdata_len = offset + bytes; + } + return ret; } -static int send_cert(CalcHandle *h) +static int buffer_clear_data(CalcHandle * h, int, char * input) { - int ret = -1; + int ret = 0; - fprintf(stderr, "Not implemented yet\n"); + memset((void *)pktdata, 0, sizeof(pktdata)); + pktdata_len = 0; return ret; } -static int recv_cert(CalcHandle *h) +static /* __attribute__((always_inline)) */ int reg_op(CalcHandle * h, int, char * input, void (* op)(unsigned int regno, uint64_t val)) { - int ret = -1; + int ret; + uint64_t val; + unsigned int regno; - fprintf(stderr, "Not implemented yet\n"); + ret = parse_reg_commands_args(input, &val, ®no); + if (ret) return 1; + else + { + op(regno, val); + } return ret; } -static int rename_var(CalcHandle* h) +static int reg_mov(CalcHandle * h, int, char * input) { - VarEntry src; - VarEntry dst; + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] = val; }); +} - memset(&src, 0, sizeof(src)); - if (!read_varname(h, &src, " current")) - { - return 0; - } - memset(&dst, 0, sizeof(dst)); - if (!read_varname(h, &dst, " new")) - { - return 0; - } +static int reg_add(CalcHandle * h, int, char * input) +{ + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] += val; }); +} - return ticalcs_calc_rename_var(h, &src, &dst); +static int reg_sub(CalcHandle * h, int, char * input) +{ + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] -= val; }); } -static int archive_var(CalcHandle* h) +static int reg_and(CalcHandle * h, int, char * input) { - VarEntry ve; + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] &= val; }); +} - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) - { - return 0; - } +static int reg_or(CalcHandle * h, int, char * input) +{ + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] |= val; }); +} - return ticalcs_calc_change_attr(h, &ve, ATTRB_ARCHIVED); +static int reg_xor(CalcHandle * h, int, char * input) +{ + return reg_op(h, 1, input, [](unsigned int regno, uint64_t val) { registers[regno] ^= val; }); } -static int unarchive_var(CalcHandle* h) +static int raw_send_data(CalcHandle * h, int, char * input) { - VarEntry ve; + int ret; - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) + ret = buffer_set_data(h, 1, (char *)"0"); + if (!ret) { - return 0; + printf("raw_send_data: %u\n", pktdata_len); + ret = ticables_cable_send(ticalcs_cable_get(h), pktdata, pktdata_len); } - return ticalcs_calc_change_attr(h, &ve, ATTRB_NONE); + return ret; } -static int lock_var(CalcHandle* h) +static int raw_send_data_from_buffer(CalcHandle * h, int, char * input) { - VarEntry ve; + int ret; + uint32_t offset = 0; + uint32_t length = 0; + char * token; + char * saveptr = NULL; - memset(&ve, 0, sizeof(ve)); - if (!read_varname(h, &ve, "")) + printf("Enter nothing, offset, or offset and length: "); + token = STRTOK(input, " ", &saveptr); + if (NULL != token) { - return 0; + // There's at least an offset. + ret = parse_check_uint32(token, &offset, sizeof(pktdata) / 2); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL != token) + { + // There's also a length. + ret = parse_check_uint32(token, &length, sizeof(pktdata) / 2); + if (ret) return 1; + } + // else do nothing, length was already initialized. } + // else do nothing, offset and length were already initialized. + + ret = ticables_cable_send(ticalcs_cable_get(h), pktdata + offset, length); - return ticalcs_calc_change_attr(h, &ve, ATTRB_LOCKED); + return ret; } -static int send_all_vars_backup(CalcHandle *h) +static int raw_recv_data(CalcHandle * h, int, char * input) { - int ret = -1; + int ret; + uint32_t length; + + printf("Enter length of raw data to be read: "); + ret = parse_check_uint32(input, &length, sizeof(pktdata) / 2); + if (ret) return 1; + + fprintf(stderr, "%u\n", length); + ret = ticables_cable_recv(ticalcs_cable_get(h), pktdata, length); - fputs("Not implemented yet\n", stderr); + if (!ret) + { + pktdata_len = length; + hexdump(pktdata, length); + } return ret; } -static int recv_all_vars_backup(CalcHandle *h) +static int dbus_send_pkt(CalcHandle * h, int, char * input) { - int ret = -1; + int ret; + uint8_t target = 0; + uint8_t cmd = 0; + uint16_t slen = 0; + uint32_t length = 0; + + // Entering the length is necessary for e.g. the simple commands, see cmd68k.cc and cmdz80.cc. + printf("Enter target (mid), cmd and length: "); + ret = scan_print_output_3(input, "%" SCNi8 " %" SCNi8 " %" SCNi16, "%" PRIu8 " %" PRIu8 " %" PRIu16, &target, &cmd, &slen, target, cmd, slen); + if (ret < 3) + { + fputs("Missing parameters\n", stderr); + return 1; + } - fputs("Not implemented yet\n", stderr); + printf("%d\t%u\t%u\t%u\n", ret, target, cmd, slen); + if (slen != 0) + { + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata, sizeof(pktdata) / 2, &length, "raw data", xstr(INBUF_DATA_SIZE)); + } + else + { + ret = 0; + length = slen; + } + printf("%d\t%u\n", ret, length); + if (!ret) + { + pktdata_len = length; + if ((uint32_t)slen > length) + { + fputs("Note: declared length is larger than the given hex data\n", stderr); + } + // Special case for packets without data. + ret = dbus_send(h, target, cmd, slen, slen == 0 ? NULL : pktdata); + printf("%d\n", ret); + } return ret; } -static int probe_calc(CalcHandle *h) +static int dbus_recv_header(CalcHandle * h, int, char * input) { - int m = 0; - int p = 0; int ret; - CalcModel model = CALC_NONE; + uint32_t offset = 0; - printf("Enter cable & port for probing (c p): "); - ret = scanf("%d %d", &m, &p); - if (!isatty(0)) + printf("Enter nothing or offset: "); + ret = parse_check_uint32(input, &offset, sizeof(pktdata) / 2); + // Don't need to test ret here, the argument is optional + + ret = dbus_recv_header(h, pktdata + offset, pktdata + offset + 1, (uint16_t *)(pktdata + offset + 2)); + if (!ret) { - printf("%d %d", m, p); + puts("Successfully received header"); + pktdata_len = offset + *(uint16_t *)(pktdata + offset + 2); + hexdump(pktdata + offset, 4); } - if (ret < 2) + else { - return 0; + fputs("Failed to receive header\n", stderr); } - ret = ticalcs_probe((CableModel)m, (CablePort)p, &model, !0); - //ticalcs_probe_calc(h->cable, &model); - //ticalcs_probe_usb_calcs(h->cable, &model); - printf("Found: <%s>\n", ticalcs_model_to_string(model)); - return ret; } -static int raw_send_data(CalcHandle *h) +static int dbus_recv_data(CalcHandle * h, int, char * input) { int ret; - char buffer[262144 + 12 + 2]; - uint8_t data[65536 + 6]; + uint32_t offset = 0; uint32_t length = 0; + uint16_t slength; + char * token; + char * saveptr = NULL; + + printf("Enter offset and length: "); + token = STRTOK(input, " ", &saveptr); + if (NULL != token) + { + // There's at least an offset. + ret = parse_check_uint32(token, &offset, sizeof(pktdata)); + if (ret) return 1; + + token = STRTOK(NULL, " ", &saveptr); + if (NULL != token) + { + // There's also a length. + ret = parse_check_uint32(token, &length, sizeof(pktdata) / 2); + if (ret) return 1; + } + else + { + fputs("Missing length\n", stderr); + return 1; + } + } + else + { + fputs("Missing offset\n", stderr); + return 1; + } + + if (offset + length >= sizeof(pktdata)) + { + fputs("Offset + length is too large\n", stderr); + return 1; + } - ret = get_hex_input(buffer, sizeof(buffer), data, sizeof(data), &length, "raw data", "262156"); + slength = (uint16_t)length; + ret = dbus_recv_data(h, &slength, pktdata + offset); if (!ret) { - ret = ticables_cable_send(ticalcs_cable_get(h), data, length); + puts("Successfully received data"); + pktdata_len = offset + slength; + hexdump(pktdata + offset, slength); + } + else + { + fputs("Failed to receive data\n", stderr); } return ret; } -static int raw_recv_data(CalcHandle *h) +static int dbus_recv(CalcHandle * h, int, char * input) { int ret; - uint32_t length; - uint8_t data[65536 + 6]; - uint8_t * ptr; + uint32_t offset = 0; - printf("Enter length of raw data to be read: "); - ret = scan_print_output("%u", "%u", &length, length); - if (ret < 1) - { - return 0; - } - if ((int32_t)length < 0) + printf("Enter nothing or offset: "); + ret = parse_check_uint32(input, &offset, sizeof(pktdata) / 2); + // Don't need to test ret here, the argument is optional + + ret = dbus_recv(h, pktdata + offset, pktdata + offset + 1, (uint16_t *)(pktdata + offset + 2), pktdata + offset + 4); + if (!ret) { - fputs("Negative length, skipping", stderr); - return 0; + puts("Successfully received header + data"); + pktdata_len = offset + *(uint16_t *)(pktdata + offset + 2); + hexdump(pktdata + offset, pktdata_len - offset); } - fprintf(stderr, "%u\n", length); - ret = ticables_cable_recv(ticalcs_cable_get(h), data, length); - - fputs("\n\t", stdout); - ptr = data; - for (uint32_t i = 0; i < length;) + else { - printf("%02X ", *ptr++); - if (!(++i & 15)) - { - fputs("\n\t", stdout); - } + fputs("Failed to receive header + data\n", stderr); } - putchar('\n'); return ret; } -static int dbus_send_pkt(CalcHandle *h) +static int dusb_send_rpkt(CalcHandle * h, int, char *) { int ret = -1; @@ -819,7 +1764,7 @@ static int dbus_send_pkt(CalcHandle *h) return ret; } -static int dbus_recv_header(CalcHandle *h) +static int dusb_recv_rpkt(CalcHandle * h, int, char *) { int ret = -1; @@ -828,7 +1773,7 @@ static int dbus_recv_header(CalcHandle *h) return ret; } -static int dbus_recv_data(CalcHandle *h) +static int nsp_send_rpkt(CalcHandle * h, int, char *) { int ret = -1; @@ -837,7 +1782,7 @@ static int dbus_recv_data(CalcHandle *h) return ret; } -static int dusb_send_rpkt(CalcHandle *h) +static int nsp_recv_rpkt(CalcHandle * h, int, char *) { int ret = -1; @@ -846,148 +1791,168 @@ static int dusb_send_rpkt(CalcHandle *h) return ret; } -static int dusb_recv_rpkt(CalcHandle *h) +static int rdmp_send_dumper(CalcHandle * h, int, char * input) { - int ret = -1; + int ret; + char filename[FILENAME_DATA_SIZE + 1]; - fputs("Not implemented\n", stderr); + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = rd_send_dumper2(h, filename); return ret; } -static int nsp_send_rpkt(CalcHandle *h) +static int rdmp_is_ready(CalcHandle * h, int, char * input) { - int ret = -1; + int ret; + char filename[FILENAME_DATA_SIZE + 1]; - fputs("Not implemented\n", stderr); + ret = read_filename(filename, " for variable"); + if (ret < 1) + { + return 1; + } + + ret = rd_is_ready(h); return ret; } -static int nsp_recv_rpkt(CalcHandle *h) +static int rdmp_read_dump(CalcHandle * h, int, char * input) { - int ret = -1; + int ret; + char filename[FILENAME_DATA_SIZE + 1]; - fputs("Not implemented\n", stderr); + ret = read_filename(filename, " for output ROM dump"); + if (ret < 1) + { + return 1; + } + + ret = rd_read_dump(h, filename); return ret; } -static int dbus_dissect_pkt(CalcHandle *h) +static int dbus_dissect_pkt(CalcHandle * h, int, char * input) { int ret; - char buffer[262144 + 12 + 2]; - uint8_t data[65536 + 6]; uint32_t length = 0; int model; printf("Enter calc model (usually 1-12, 16-17): "); - ret = scan_print_output("%d", "%d", &model, model); + ret = scan_print_output_1(input, "%d", "%d", &model, model); if (ret < 1) { - return 0; + fputs("Missing parameters\n", stderr); + return 1; } - ret = get_hex_input(buffer, sizeof(buffer), data, sizeof(data), &length, "DBUS packet", "262156"); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata2, sizeof(pktdata2), &length, "DBUS packet", xstr(INBUF_DATA_SIZE)); if (!ret) { - ret = dbus_dissect((CalcModel)model, stderr, data, length); + ret = dbus_dissect((CalcModel)model, stderr, pktdata2, length); } return ret; } -static int dusb_dissect_rpkt(CalcHandle *h) +static int dusb_dissect_rpkt(CalcHandle * h, int, char * input) { int ret; uint8_t ep = 2; // Assume PC -> TI. uint8_t first = 1; // Assume all packets are first packets. - char buffer[4096 + 2]; - uint8_t data[sizeof(((DUSBRawPacket *)0)->data)]; uint32_t length = 0; int model; printf("Enter calc model (usually 13, 14, 18-21): "); - ret = scan_print_output("%d", "%d", &model, model); + ret = scan_print_output_1(input, "%d", "%d", &model, model); if (ret < 1) { - return 0; + fputs("Missing parameters\n", stderr); + return 1; } - ret = get_hex_input(buffer, sizeof(buffer), data, sizeof(data), &length, "raw DUSB packet", "4096"); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata2, sizeof(((DUSBRawPacket *)0)->data), &length, "raw DUSB packet", xstr(INBUF_DATA_SIZE)); if (!ret) { - ret = dusb_dissect((CalcModel)model, stderr, data, length, ep, &first); + ret = dusb_dissect((CalcModel)model, stderr, pktdata2, length, ep, &first); } return ret; } -static int nsp_dissect_rpkt(CalcHandle *h) +static int nsp_dissect_rpkt(CalcHandle * h, int, char * input) { int ret; uint8_t ep = 2; // Assume PC -> TI. - char buffer[1536 + 2]; - uint8_t data[sizeof(((NSPRawPacket *)0)->data)]; uint32_t length = 0; int model; printf("Enter calc model (usually 15): "); - ret = scan_print_output("%d", "%d", &model, model); + ret = scan_print_output_1(input, "%d", "%d", &model, model); if (ret < 1) { - return 0; + fputs("Missing parameters\n", stderr); + return 1; } - ret = get_hex_input(buffer, sizeof(buffer), data, sizeof(data), &length, "raw NSP packet", "1536"); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata2, sizeof(((NSPRawPacket *)0)->data), &length, "raw NSP packet", xstr(INBUF_DATA_SIZE)); if (!ret) { - ret = nsp_dissect((CalcModel)model, stderr, data, length, ep); + ret = nsp_dissect((CalcModel)model, stderr, pktdata2, length, ep); } return ret; } -static int ti83p_dump(CalcHandle *h) +static int ti83p_dump(CalcHandle * h, int, char * input) { + int ret; char filename[FILENAME_DATA_SIZE + 7]; - uint8_t buffer[0x4100]; int page; - int ret; uint16_t length; FILE *f; filename[0] = 0; printf("Enter page number for dumping: "); - ret = scan_print_output("%d", "%d", &page, page); + ret = scan_print_output_1(input, "%d", "%d", &page, page); if (ret < 1) { - return 0; + fputs("Missing parameters\n", stderr); + return 1; } ret = read_filename(filename, " for memory page dump"); - if (ret >= 1) + if (ret < 1) { - f = fopen(filename, "wb"); - if (f != NULL) - { - memset(buffer, 0, sizeof(buffer)); + return 1; + } - if ( (ti73_send_DUMP(h, (uint16_t)page) == 0) - && (ti73_recv_ACK(h, NULL) == 0) - && (ti73_recv_XDP(h, &length, buffer) == 0) - && (ti73_send_ACK(h) == 0)) - { - fwrite(buffer, length, 1, f); - } - fclose(f); + f = fopen(filename, "wb"); + if (f != NULL) + { + //memset(pktdata, 0, sizeof(pktdata)); + + if ( (ti73_send_DUMP(h, (uint16_t)page) == 0) + && (ti73_recv_ACK(h, NULL) == 0) + && (ti73_recv_XDP(h, &length, pktdata) == 0) + && (ti73_send_ACK(h) == 0)) + { + fwrite(pktdata, length, 1, f); } + fclose(f); } return ret; } -static int ti83p_eke(CalcHandle *h) +static int ti83p_eke(CalcHandle * h, int, char *) { int ret; @@ -1005,7 +1970,7 @@ static int ti83p_eke(CalcHandle *h) return ret; } -static int ti83p_dke(CalcHandle *h) +static int ti83p_dke(CalcHandle * h, int, char *) { int ret; @@ -1023,7 +1988,7 @@ static int ti83p_dke(CalcHandle *h) return ret; } -static int ti83p_eld(CalcHandle *h) +static int ti83p_eld(CalcHandle * h, int, char *) { int ret; @@ -1041,7 +2006,7 @@ static int ti83p_eld(CalcHandle *h) return ret; } -static int ti83p_dld(CalcHandle *h) +static int ti83p_dld(CalcHandle * h, int, char *) { int ret; @@ -1059,11 +2024,10 @@ static int ti83p_dld(CalcHandle *h) return ret; } -static int ti83p_gid(CalcHandle *h) +static int ti83p_gid(CalcHandle * h, int, char *) { - uint8_t buffer[0x10]; - uint16_t length; int ret; + uint16_t length; ret = ti73_send_GID(h); if (!ret) @@ -1073,7 +2037,7 @@ static int ti83p_gid(CalcHandle *h) if (!ret) { puts("ACK received"); - ret = ti73_recv_XDP(h, &length, buffer); + ret = ti73_recv_XDP(h, &length, pktdata2); if (!ret) { puts("XDP received"); @@ -1083,7 +2047,7 @@ static int ti83p_gid(CalcHandle *h) puts("ACK received"); for (uint16_t i = 0; i < length; i++) { - printf("%02X ", buffer[i]); + printf("%02X ", pktdata2[i]); } putchar('\n'); } @@ -1094,17 +2058,16 @@ static int ti83p_gid(CalcHandle *h) return ret; } -static int ti83p_rid(CalcHandle *h) +static int ti83p_rid(CalcHandle * h, int, char *) { - uint8_t buffer[0x30]; - uint16_t length; int ret; + uint16_t length; ret = ti73_send_RID(h); if (!ret) { puts("RID successfully sent"); - ret = ti73_recv_SID(h, &length, buffer); + ret = ti73_recv_SID(h, &length, pktdata2); if (!ret) { puts("SID receive"); @@ -1114,7 +2077,7 @@ static int ti83p_rid(CalcHandle *h) puts("ACK received"); for (uint16_t i = 0; i < length; i++) { - printf("%02X ", buffer[i]); + printf("%02X ", pktdata2[i]); } putchar('\n'); } @@ -1124,40 +2087,43 @@ static int ti83p_rid(CalcHandle *h) return ret; } -static int ti83p_sid(CalcHandle *h) +static int ti83p_sid(CalcHandle * h, int, char *) { - static uint8_t DATA[] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 - }; int ret; + uint32_t length = 0; - ret = ti73_send_SID(h, DATA); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata, 32, &length, "raw data", xstr(INBUF_DATA_SIZE)); if (!ret) { - puts("SID successfully sent"); - ret = ti73_recv_ACK(h, NULL); - if (!ret) + pktdata_len = length; + if (length >= 32) + { + ret = ti73_send_SID(h, pktdata); + if (!ret) + { + puts("SID successfully sent"); + ret = ti73_recv_ACK(h, NULL); + if (!ret) + { + puts("ACK successfully received"); + } + } + } + else { - puts("ACK received successful"); + fputs("Insufficient length\n", stderr); } } return ret; } -#include "../src/dusb_cmd.h" - -static int dusb_get_param_ids(CalcHandle * h) +static int dusb_get_param_ids(CalcHandle * h, int, char *) { int ret; - char buffer[4096 + 2]; - uint16_t data[512]; uint32_t length = 0; - ret = get_hex_input(buffer, sizeof(buffer), (uint8_t *)data, sizeof(data), &length, "parameter IDs", "4096"); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata2, 512 * 2, &length, "parameter IDs", xstr(INBUF_DATA_SIZE)); if (!ret) { if ((length & 1) == 0) @@ -1165,7 +2131,7 @@ static int dusb_get_param_ids(CalcHandle * h) DUSBCalcParam **params; params = dusb_cp_new_array(h, length / 2); - ret = dusb_cmd_s_param_request(h, length / 2, data); + ret = dusb_cmd_s_param_request(h, length / 2, (uint16_t *)pktdata2); if (!ret) { ret = dusb_cmd_r_param_data(h, length / 2, params); @@ -1202,25 +2168,24 @@ static int dusb_get_param_ids(CalcHandle * h) return ret; } -static int dusb_set_param_id(CalcHandle * h) +static int dusb_set_param_id(CalcHandle * h, int, char * input) { int ret; - char buffer[4096 + 2]; - uint8_t * data; uint32_t length = 0; unsigned int param_id; - data = (uint8_t *)dusb_cp_alloc_data(h, 2048); + uint8_t * data = (uint8_t *)dusb_cp_alloc_data(h, 2048); printf("Enter DUSB parameter ID to be set (usually < 0x60): "); - ret = scan_print_output("%u", "%u", ¶m_id, param_id); + ret = scan_print_output_1(input, "%u", "%u", ¶m_id, param_id); if (ret < 1) { dusb_cp_free_data(h, data); - return 0; + fputs("Missing parameters\n", stderr); + return 1; } - ret = get_hex_input(buffer, sizeof(buffer), data, sizeof(data), &length, "raw data", "4096"); + ret = get_hex_input(inbuf, sizeof(inbuf), pktdata2, sizeof(pktdata2), &length, "raw data", xstr(INBUF_DATA_SIZE)); if (!ret) { DUSBCalcParam *param; @@ -1243,58 +2208,58 @@ static int dusb_set_param_id(CalcHandle * h) return ret; } -static int nsp_send_key(CalcHandle *h) +static int nsp_send_key(CalcHandle * h, int, char *) { - //static const uint8_t HOME[] = {0x00, 0xFD, 0x00}; + int ret; static const uint8_t A[] = {97, 102, 0}; - //static const uint8_t ZERO[] = {48, 80, 0}; static const uint8_t ONE[] = {49, 115, 0}; - //static const uint8_t TWO[] = {50, 83, 0}; static const uint8_t THREE[] = {51, 51, 0}; - //static const uint8_t FOUR[] = {52, 114, 0}; static const uint8_t FIVE[] = {53, 82, 0}; - //static const uint8_t SIX[] = {54, 50, 0}; static const uint8_t SEVEN[] = {55, 113, 0}; - //static const uint8_t EIGHT[] = {56, 81, 0}; static const uint8_t NINE[] = {57, 49, 0}; - ticalcs_calc_send_key(h, KEYNSP_HOME); - nsp_cmd_s_keypress_event(h, A); - ticalcs_calc_send_key(h, KEYNSP_ZERO); - nsp_cmd_s_keypress_event(h, ONE); - ticalcs_calc_send_key(h, KEYNSP_TWO); - nsp_cmd_s_keypress_event(h, THREE); - ticalcs_calc_send_key(h, KEYNSP_FOUR); - nsp_cmd_s_keypress_event(h, FIVE); - ticalcs_calc_send_key(h, KEYNSP_SIX); - nsp_cmd_s_keypress_event(h, SEVEN); - ticalcs_calc_send_key(h, KEYNSP_EIGHT); - nsp_cmd_s_keypress_event(h, NINE); - ticalcs_calc_send_key(h, KEYNSP_HOME); + do + { + ret = ticalcs_calc_send_key(h, KEYNSP_HOME); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, A); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_ZERO); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, ONE); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_TWO); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, THREE); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_FOUR); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, FIVE); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_SIX); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, SEVEN); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_EIGHT); if (ret) break; + ret = nsp_cmd_s_keypress_event(h, NINE); if (ret) break; + ret = ticalcs_calc_send_key(h, KEYNSP_HOME); + } while(0); - return 0; + return ret; } -static int nsp_remote_mgmt(CalcHandle * h) +static int nsp_remote_mgmt(CalcHandle * h, int, char *) { - int retval = 0; + int ret; static uint8_t data[9] = { 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; - is_ready(h); - - printf("Packet 1\n"); - retval = nsp_cmd_s_generic_data(h, sizeof(data) / sizeof(data[0]), data, NSP_SID_REMOTE_MGMT, 0x00); - // Packets returned by the calculator have weird data nowadays. - if (!retval || retval == ERR_INVALID_PACKET) + ret = is_ready(h, 1, NULL); + if (!ret) { - uint32_t size; - uint8_t * data2 = NULL; - printf("Packet 2\n"); - retval = nsp_cmd_r_generic_data(h, &size, &data2); - g_free(data2); + printf("Packet 1\n"); + ret = nsp_cmd_s_generic_data(h, sizeof(data) / sizeof(data[0]), data, NSP_SID_REMOTE_MGMT, 0x00); + // Packets returned by the calculator have weird data nowadays. + if (!ret || ret == ERR_INVALID_PACKET) + { + uint32_t size; + uint8_t * data2 = NULL; + printf("Packet 2\n"); + ret = nsp_cmd_r_generic_data(h, &size, &data2); + g_free(data2); + } } - return retval; + return ret; } static ticables_event_hook_type old_ticables_event_hook; @@ -1302,105 +2267,180 @@ static ticalcs_event_hook_type old_ticalcs_event_hook; static int cables_event_hook(CableHandle * handle, uint32_t event_count, const CableEventData * event, void * user_pointer) { - int retval = 0; + int ret = 0; + if (NULL != handle && NULL != event) { // TODO } if (old_ticables_event_hook) { - retval = old_ticables_event_hook(handle, event_count, event, user_pointer); + ret = old_ticables_event_hook(handle, event_count, event, user_pointer); } - return retval; + + return ret; } static int calcs_event_hook(CalcHandle * handle, uint32_t event_count, const CalcEventData * event, void * user_pointer) { - int retval = 0; + int ret = 0; + if (NULL != handle && NULL != event) { // TODO } if (old_ticalcs_event_hook) { - retval = old_ticalcs_event_hook(handle, event_count, event, user_pointer); + ret = old_ticalcs_event_hook(handle, event_count, event, user_pointer); } - return retval; + + return ret; } -static struct +typedef struct { const char * desc; const char * scriptable_name; + uint32_t scriptable_name_len; FNCT_MENU fnct; -} fnct_menu[] = +} menu_entry; + +static menu_entry fnct_menu[] = { #define DEFINE_MENU_ENTRY(desc, method) \ - { desc, #method, method } - - // IMPORTANT NOTE: for backwards compatibility, after a scriptable name was defined, it shall never be changed. - { "Exit", "exit", NULL }, // 0 - // Front-ends for ticalcs_calc_*() which use function pointers in CalcFncts instances. - DEFINE_MENU_ENTRY("Check whether calc is ready", is_ready), - DEFINE_MENU_ENTRY("Send a key", send_key), - DEFINE_MENU_ENTRY("Execute program", execute), - DEFINE_MENU_ENTRY("Do a screenshot", recv_screen), - DEFINE_MENU_ENTRY("Get directory listing", get_dirlist), - DEFINE_MENU_ENTRY("Get available memory", get_memfree), - DEFINE_MENU_ENTRY("Send backup", send_backup), - DEFINE_MENU_ENTRY("Recv backup", recv_backup), - DEFINE_MENU_ENTRY("Send var", send_var), - DEFINE_MENU_ENTRY("Recv var", recv_var), // 10 - DEFINE_MENU_ENTRY("Send var (ns)", send_var_ns), - DEFINE_MENU_ENTRY("Recv var (ns)", recv_var_ns), - DEFINE_MENU_ENTRY("Send app", send_app), - DEFINE_MENU_ENTRY("Recv app", recv_app), - DEFINE_MENU_ENTRY("Send OS", send_os), - DEFINE_MENU_ENTRY("Get ID-LIST", recv_idlist), - DEFINE_MENU_ENTRY("Dump ROM", dump_rom), - DEFINE_MENU_ENTRY("Set clock", set_clock), - DEFINE_MENU_ENTRY("Get clock", get_clock), - DEFINE_MENU_ENTRY("Delete var", del_var), // 20 - DEFINE_MENU_ENTRY("New folder", new_folder), - DEFINE_MENU_ENTRY("Get version", get_version), - DEFINE_MENU_ENTRY("Send certificate stuff", send_cert), - DEFINE_MENU_ENTRY("Recv certificate stuff", recv_cert), - DEFINE_MENU_ENTRY("Rename var", rename_var), - DEFINE_MENU_ENTRY("Archive var", archive_var), // - DEFINE_MENU_ENTRY("Unarchive var", unarchive_var), // These three functions wrap ticalcs_calc_change_attr() - DEFINE_MENU_ENTRY("Lock var", lock_var), // - DEFINE_MENU_ENTRY("Send all variables backup", send_all_vars_backup), - DEFINE_MENU_ENTRY("Recv all variables backup", recv_all_vars_backup), // 30 + { desc, #method, sizeof(#method) - 1, method } +// Used for signaling that a newline should be printed +#define NULL_ENTRY \ + { NULL, NULL, 0, NULL } + + // IMPORTANT NOTES: for backwards compatibility, after a scriptable name was defined, it shall never be changed. + { "GEN Exit now", "exit", 4, NULL }, // 0 + { "GEN Exit if previous operation failed", "exit_if_failed", 14, NULL }, + NULL_ENTRY, + DEFINE_MENU_ENTRY("CFG Get config value", cfg_get), + DEFINE_MENU_ENTRY("CFG Set config value", cfg_set), + NULL_ENTRY, + DEFINE_MENU_ENTRY("GEN Sleep for tenths of seconds", sleep), + DEFINE_MENU_ENTRY("GEN Set timeout in tenths of seconds", timeout), // 5 + DEFINE_MENU_ENTRY("GEN Set delay in us", delay), + NULL_ENTRY, // Probing. - DEFINE_MENU_ENTRY("Probe calc", probe_calc), - // Front-ends for raw packet sending functions. - DEFINE_MENU_ENTRY("Send raw data bytes", raw_send_data), - DEFINE_MENU_ENTRY("Recv raw data bytes", raw_recv_data), - DEFINE_MENU_ENTRY("Send DBUS packet", dbus_send_pkt), - DEFINE_MENU_ENTRY("Recv DBUS header", dbus_recv_header), - DEFINE_MENU_ENTRY("Recv DBUS data", dbus_recv_data), - DEFINE_MENU_ENTRY("Send DUSB raw packet", dusb_send_rpkt), - DEFINE_MENU_ENTRY("Recv DUSB raw packet", dusb_recv_rpkt), - DEFINE_MENU_ENTRY("Send NSP raw packet", nsp_send_rpkt), - DEFINE_MENU_ENTRY("Recv NSP raw packet", nsp_recv_rpkt), // 40 + DEFINE_MENU_ENTRY("GEN Probe calc", probe_calc), + NULL_ENTRY, + // Front-ends for ticalcs_calc_*() which use function pointers in CalcFncts instances. + DEFINE_MENU_ENTRY("FNCT Check whether calc is ready", is_ready), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send a key", send_key), + DEFINE_MENU_ENTRY("FNCT Execute program", execute), // 10 + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Do a screenshot", recv_screen), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Get directory listing", get_dirlist), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Get available memory", get_memfree), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send backup", send_backup), + DEFINE_MENU_ENTRY("FNCT Recv backup", recv_backup), // 15 + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send var", send_var), + DEFINE_MENU_ENTRY("FNCT Recv var", recv_var), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send var (ns)", send_var_ns), + DEFINE_MENU_ENTRY("FNCT Recv var (ns)", recv_var_ns), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send app", send_app), // 20 + DEFINE_MENU_ENTRY("FNCT Recv app", recv_app), + DEFINE_MENU_ENTRY("FNCT Send OS", send_os), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Get ID-LIST", recv_idlist), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Dump ROM", dump_rom), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Set clock", set_clock), // 25 + DEFINE_MENU_ENTRY("FNCT Get clock", get_clock), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Delete var", del_var), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT New folder", new_folder), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Get version", get_version), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send certificate stuff", send_cert), // 30 + DEFINE_MENU_ENTRY("FNCT Recv certificate stuff", recv_cert), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Rename var", rename_var), + // These three functions wrap ticalcs_calc_change_attr() + DEFINE_MENU_ENTRY("FNCT Archive var", archive_var), + DEFINE_MENU_ENTRY("FNCT Unarchive var", unarchive_var), + DEFINE_MENU_ENTRY("FNCT Lock var", lock_var), // 35 + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send all variables backup", send_all_vars_backup), + DEFINE_MENU_ENTRY("FNCT Recv all variables backup", recv_all_vars_backup), + NULL_ENTRY, + DEFINE_MENU_ENTRY("FNCT Send({...}) (send list data)", send_lab_equipment_data), + DEFINE_MENU_ENTRY("FNCT Get (get list data)", get_lab_equipment_data), + NULL_ENTRY, + // Front-ends for raw packet sending / receiving / manipulation functions. + DEFINE_MENU_ENTRY("BUF Enter data bytes into packet buffer", buffer_set_data), // 40 + DEFINE_MENU_ENTRY("BUF Dump data bytes from packet buffer", buffer_get_data), + NULL_ENTRY, + DEFINE_MENU_ENTRY("BUF Peek data in the packet buffer", buffer_peek_data), + DEFINE_MENU_ENTRY("BUF Poke data in the packet buffer", buffer_poke_data), + DEFINE_MENU_ENTRY("BUF Clear packet buffer", buffer_clear_data), + NULL_ENTRY, + DEFINE_MENU_ENTRY("BUF MOV register/value to register", reg_mov), // 45 + DEFINE_MENU_ENTRY("BUF ADD register/value to register", reg_add), + DEFINE_MENU_ENTRY("BUF SUB register/value to register", reg_sub), + NULL_ENTRY, + DEFINE_MENU_ENTRY("BUF AND register/value to register", reg_and), + DEFINE_MENU_ENTRY("BUF OR register/value to register", reg_or), + DEFINE_MENU_ENTRY("BUF XOR register/value to register", reg_xor), // 50 + NULL_ENTRY, + DEFINE_MENU_ENTRY("RAW Send raw data bytes (interactive)", raw_send_data), + DEFINE_MENU_ENTRY("RAW Send raw data bytes from packet buffer", raw_send_data_from_buffer), + DEFINE_MENU_ENTRY("RAW Recv raw data bytes", raw_recv_data), + NULL_ENTRY, + DEFINE_MENU_ENTRY("DBUS Send packet", dbus_send_pkt), + DEFINE_MENU_ENTRY("DBUS Recv header", dbus_recv_header), // 55 + DEFINE_MENU_ENTRY("DBUS Recv data", dbus_recv_data), + DEFINE_MENU_ENTRY("DBUS Recv header+data", dbus_recv), + NULL_ENTRY, + DEFINE_MENU_ENTRY("DUSB Send raw packet", dusb_send_rpkt), + DEFINE_MENU_ENTRY("DUSB Recv raw packet", dusb_recv_rpkt), + NULL_ENTRY, + DEFINE_MENU_ENTRY("NSP Send raw packet", nsp_send_rpkt), // 60 + DEFINE_MENU_ENTRY("NSP Recv raw packet", nsp_recv_rpkt), + NULL_ENTRY, + DEFINE_MENU_ENTRY("RDMP Send ROM dumper", rdmp_send_dumper), + DEFINE_MENU_ENTRY("RDMP Check whether ready", rdmp_is_ready), + DEFINE_MENU_ENTRY("RDMP Read ROM dump", rdmp_read_dump), + NULL_ENTRY, // Front-ends for dissection functions. - DEFINE_MENU_ENTRY("DBUS: dissect packet", dbus_dissect_pkt), - DEFINE_MENU_ENTRY("DUSB: dissect raw packet", dusb_dissect_rpkt), - DEFINE_MENU_ENTRY("NSP: dissect raw packet", nsp_dissect_rpkt), + DEFINE_MENU_ENTRY("DIS Dissect DBUS raw packet", dbus_dissect_pkt), // 65 + DEFINE_MENU_ENTRY("DIS Dissect DUSB raw packet", dusb_dissect_rpkt), + DEFINE_MENU_ENTRY("DIS Dissect NSP raw packet", nsp_dissect_rpkt), + NULL_ENTRY, // Front-ends for protocol-specific capabilities. - DEFINE_MENU_ENTRY("83+-family-specific memory dump", ti83p_dump), - DEFINE_MENU_ENTRY("83+-family-specific enable key echo", ti83p_eke), - DEFINE_MENU_ENTRY("83+-family-specific disable key echo", ti83p_dke), - DEFINE_MENU_ENTRY("83+-family-specific enable lockdown", ti83p_eld), - DEFINE_MENU_ENTRY("83+-family-specific disable lockdown", ti83p_dld), - DEFINE_MENU_ENTRY("83+-family-specific get standard calculator ID", ti83p_gid), - DEFINE_MENU_ENTRY("83+-family-specific retrieve some 32-byte memory area", ti83p_rid), // 50 - DEFINE_MENU_ENTRY("83+-family-specific set some 32-byte memory area", ti83p_sid), - DEFINE_MENU_ENTRY("DUSB: get parameter IDs", dusb_get_param_ids), - DEFINE_MENU_ENTRY("DUSB: set parameter ID", dusb_set_param_id), - DEFINE_MENU_ENTRY("Nspire-specific and generic send key", nsp_send_key), - DEFINE_MENU_ENTRY("NSP: test remote management stuff", nsp_remote_mgmt), - + DEFINE_MENU_ENTRY("DBUS 83+ Memory dump", ti83p_dump), + NULL_ENTRY, + DEFINE_MENU_ENTRY("DBUS 83+ Enable key echo", ti83p_eke), + DEFINE_MENU_ENTRY("DBUS 83+ Disable key echo", ti83p_dke), // 70 + NULL_ENTRY, + DEFINE_MENU_ENTRY("DBUS 83+ Enable lockdown", ti83p_eld), + DEFINE_MENU_ENTRY("DBUS 83+ Disable lockdown", ti83p_dld), + NULL_ENTRY, + DEFINE_MENU_ENTRY("DBUS 83+ Get standard calculator ID", ti83p_gid), + DEFINE_MENU_ENTRY("DBUS 83+ Get some 32-byte memory area", ti83p_rid), + DEFINE_MENU_ENTRY("DBUS 83+ Set some 32-byte memory area", ti83p_sid), // 75 + NULL_ENTRY, + DEFINE_MENU_ENTRY("DUSB Get parameter IDs", dusb_get_param_ids), + DEFINE_MENU_ENTRY("DUSB Set parameter ID", dusb_set_param_id), + NULL_ENTRY, + DEFINE_MENU_ENTRY("NSP Send key (specific and generic)", nsp_send_key), + NULL_ENTRY, + DEFINE_MENU_ENTRY("NSP Test remote management stuff", nsp_remote_mgmt), + NULL_ENTRY, +#undef NULL_ENTRY #undef DEFINE_MENU_ENTRY }; @@ -1411,12 +2451,15 @@ int main(int argc, char **argv) CalcModel calc_model = CALC_NONE; CableHandle* cable = NULL; CalcHandle* calc = NULL; - int err = 0, i; + int err = 0, preverr = 0, i; + unsigned int j; int do_exit = 0; char* colon; int do_probe = 1; + int quiet = 0; + int first = 1; - while ((i = getopt(argc, argv, "c:m:n")) != -1) + while ((i = getopt(argc, argv, "c:m:nq")) != -1) { if (i == 'c') { @@ -1436,6 +2479,10 @@ int main(int argc, char **argv) { do_probe = 0; } + else if (i == 'q') + { + quiet = 1; + } else { fprintf(stderr, "Usage: %s [-n (no probe)] [-c CABLE[:PORT]] [-m CALC]\n", argv[0]); @@ -1466,21 +2513,21 @@ int main(int argc, char **argv) { fprintf(stderr, "No supported USB cable found\n"); ticables_free_usb_device_info(list); - goto end; + goto end2; } if (ndevices > 1) { fprintf(stderr, "More than one device is not supported by test_ticalcs_2 at the moment\n"); ticables_free_usb_device_info(list); - goto end; + goto end2; } if (list[0].family == CABLE_FAMILY_UNKNOWN) { fprintf(stderr, "Unknown cable\n"); ticables_free_usb_device_info(list); - goto end; + goto end2; } cable_model = list[0].family == CABLE_FAMILY_DBUS ? CABLE_SLV : CABLE_USB; @@ -1489,6 +2536,7 @@ int main(int argc, char **argv) ticables_free_usb_device_info(list); } + printf("Cable is %d (%s), port is #%d\n", cable_model, ticables_model_to_string(cable_model), port_number); cable = ticables_handle_new(cable_model, port_number); if (cable == NULL) { @@ -1507,6 +2555,7 @@ int main(int argc, char **argv) } } + printf("Calc is %d (%s)\n", calc_model, ticalcs_model_to_string(calc_model)); calc = ticalcs_handle_new(calc_model); if (calc == NULL) { @@ -1527,47 +2576,128 @@ int main(int argc, char **argv) do { - char input[32 + 2]; + char * ptr; unsigned int choice; // Display menu printf("Choose an action:\n"); - for (i = 0; i < (int)(sizeof(fnct_menu)/sizeof(fnct_menu[0])); i++) + if (!quiet) { - printf("%2d. %s\n", i, fnct_menu[i].desc); + for (i = 0, j = 0; i < (int)(sizeof(fnct_menu)/sizeof(fnct_menu[0])); i++) + { + if (NULL != fnct_menu[i].desc) + { + printf("%2d. %-45s", j, fnct_menu[i].desc); + j++; + } + else + { + putchar('\n'); + } + } + printf("Your choice: "); } - printf("Your choice: "); - err = scan_print_output("%32s", "%s", input, input); - //printf("%d %02X\n", err, input[0]); - if (err < 1) + inbuf2[0] = 0; + ptr = fgets(inbuf2, 128, stdin); + + //printf("%d %02X\n", err, inbuf2[0]); + if (NULL == ptr) { - // Couldn't read a single char; try again, in a rate-limited way. +/* // Couldn't read a single char; try again, in a rate-limited way. #ifdef __WIN32__ Sleep(1000); #else sleep(1); -#endif - continue; +#endif*/ + choice = 0; } else { - //printf("%d %02X %u\n", err, input[0], choice); - if (input[0] == 0x04) + // Swallow newline. + if (inbuf2[strlen(inbuf2) - 1] == '\n') + { + inbuf2[strlen(inbuf2) - 1] = 0; + } + printf("%02X\t\"%s\"\n", inbuf2[0], inbuf2); + + // Special handling for some commands. + if (first) + { + first = 0; + if (!isatty(0)) + { + if (!strncmp(inbuf2, "version ", sizeof("version ") - 1)) + { + err = sscanf(inbuf2 + sizeof("version ") - 1, "%i", &version); + if (err < 1 || ((int32_t)version < 0)) + { + fputs("Invalid version command\n", stderr); + choice = 0; + } + else if (version > CURRENT_SCRIPT_VERSION) + { + fputs("Script requests newer version than this client supports\n", stderr); + choice = 0; + } + else + { + puts("Good version command"); + continue; + } + } + else + { + fputs("Scripts must start with version command\n", stderr); + choice = 0; + } + } + } + + //printf("%d %02X %u\n", err, inbuf2[0], choice); + if (inbuf2[0] == 0x00) + { + // Single newline, do nothing. + continue; + //choice = UINT_MAX; + } + else if (inbuf2[0] == 0x04 || !strcmp(inbuf2, "exit")) { // End of input ? choice = 0; } + else if (!strcmp(inbuf2, "exit_if_failed")) + { + if (preverr != 0) + { + puts("The previous operation failed, exiting"); + choice = 0; + } + } + else if (!strncmp(inbuf2, "version ", sizeof("version ") - 1)) + { + fputs("Swallowing spurious version command\n", stderr); + continue; + } else { - err = sscanf(input, "%u", &choice); + puts("Scanning"); + err = sscanf(inbuf2, "%u", &choice); if (err < 1) { - for (i = 0; i < (int)(sizeof(fnct_menu)/sizeof(fnct_menu[0])); i++) + for (i = 2, j = 2; i < (int)(sizeof(fnct_menu)/sizeof(fnct_menu[0])); i++) { - if (!strcmp(fnct_menu[i].scriptable_name, input)) + // strstr and the second check are used to cope with names which are prefixes of others, e.g. send_var / send_var_ns, + // while allowing for other parameters on the same line. + if (NULL != fnct_menu[i].scriptable_name) { - choice = i; - break; + if ( (strstr(inbuf2, fnct_menu[i].scriptable_name) == inbuf2) + && (inbuf2[fnct_menu[i].scriptable_name_len] != '_') + ) + { + choice = j; + break; + } + j++; } } } @@ -1581,15 +2711,35 @@ int main(int argc, char **argv) } else { - err = 0; + printf("Choice is %u\n", choice); + preverr = 0; // Process choice - if (choice < sizeof(fnct_menu)/sizeof(fnct_menu[0]) && fnct_menu[choice].fnct) + if (choice < sizeof(fnct_menu)/sizeof(fnct_menu[0])) { - err = (fnct_menu[choice].fnct)(calc); + for (i = 2, j = 2; i < (int)(sizeof(fnct_menu)/sizeof(fnct_menu[0])); i++) + { + if (NULL != fnct_menu[i].fnct) + { + if (j == choice) + { + // Swallow function name + printf("Will invoke %s\n", fnct_menu[i].scriptable_name); + ptr = strchr(inbuf2, ' '); + preverr = (fnct_menu[i].fnct)(calc, 1, nullptr == ptr ? ptr : ptr + 1); + break; + } + j++; + } + } } - if (err) + if (preverr) { - fprintf(stderr, "Function %d returned %d\n", choice, err); + fprintf(stderr, "Function %d returned %d\n", choice, preverr); + if (cfg_exit_on_failure) + { + fputs("Function failed and exit on failure enabled, bailing out\n", stderr); + do_exit = 1; + } } } printf("\n"); @@ -1603,5 +2753,9 @@ int main(int argc, char **argv) ticalcs_handle_del(calc); ticables_handle_del(cable); +end2: + ticalcs_library_exit(); + ticables_library_exit(); + return err; } diff --git a/libticalcs/trunk/tests/torture_ticalcs.c b/libticalcs/trunk/tests/torture_ticalcs.c index 3c7296fac..1e6d0adde 100644 --- a/libticalcs/trunk/tests/torture_ticalcs.c +++ b/libticalcs/trunk/tests/torture_ticalcs.c @@ -136,6 +136,15 @@ static void torture_ticalcs(void) PRINTF(ticalcs_calc_send_cert, INT, (void *)0x12345678, NULL); PRINTF(ticalcs_calc_recv_cert, INT, NULL, (void *)0x12345678); PRINTF(ticalcs_calc_recv_cert, INT, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_send_all_vars_backup, INT, NULL, (void *)0x12345678); + PRINTF(ticalcs_calc_send_all_vars_backup, INT, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_recv_all_vars_backup, INT, NULL, (void *)0x12345678); + PRINTF(ticalcs_calc_recv_all_vars_backup, INT, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_send_lab_equipment_data, INT, NULL, -1, (void *)0x12345678); + PRINTF(ticalcs_calc_send_lab_equipment_data, INT, (void *)0x12345678, -1, NULL); + + PRINTF(ticalcs_calc_get_lab_equipment_data, INT, NULL, -1, (void *)0x12345678); + PRINTF(ticalcs_calc_get_lab_equipment_data, INT, (void *)0x12345678, -1, NULL); PRINTF(ticalcs_calc_send_tigroup, INT, NULL, (void *)0x12345678, -1); PRINTF(ticalcs_calc_send_tigroup, INT, (void *)0x12345678, NULL, -1); @@ -145,6 +154,7 @@ static void torture_ticalcs(void) PRINTF(ticalcs_calc_send_backup2, INT, (void *)0x12345678, NULL); PRINTF(ticalcs_calc_recv_backup2, INT, NULL, (void *)0x12345678); PRINTF(ticalcs_calc_recv_backup2, INT, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_send_var2, INT, NULL, -1, (void *)0x12345678); PRINTF(ticalcs_calc_send_var2, INT, (void *)0x12345678, -1, NULL); PRINTF(ticalcs_calc_recv_var2, INT, NULL, -1, (void *)0x12345678, (void *)0x12345678); @@ -156,6 +166,7 @@ static void torture_ticalcs(void) PRINTF(ticalcs_calc_recv_var_ns2, INT, NULL, -1, (void *)0x12345678, (void *)0x12345678); PRINTF(ticalcs_calc_recv_var_ns2, INT, (void *)0x12345678, -1, NULL, (void *)0x12345678); PRINTF(ticalcs_calc_recv_var_ns2, INT, (void *)0x12345678, -1, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_send_app2, INT, NULL, (void *)0x12345678); PRINTF(ticalcs_calc_send_app2, INT, (void *)0x12345678, NULL); PRINTF(ticalcs_calc_recv_app2, INT, NULL, (void *)0x12345678, (void *)0x12345678); @@ -167,7 +178,13 @@ static void torture_ticalcs(void) PRINTF(ticalcs_calc_recv_cert2, INT, NULL, (void *)0x12345678); PRINTF(ticalcs_calc_recv_cert2, INT, (void *)0x12345678, NULL); PRINTF(ticalcs_calc_send_os2, INT, NULL, (void *)0x12345678); + PRINTF(ticalcs_calc_send_os2, INT, (void *)0x12345678, NULL); + PRINTF(ticalcs_calc_send_lab_equipment_data2, INT, NULL, -1, 0, (void *)0x12345678); + PRINTF(ticalcs_calc_send_lab_equipment_data2, INT, (void *)0x12345678, -1, 0, NULL); + PRINTF(ticalcs_calc_get_lab_equipment_data2, INT, NULL, -1, 0, (void *)0x12345678); + PRINTF(ticalcs_calc_get_lab_equipment_data2, INT, (void *)0x12345678, -1, 0, NULL); + PRINTFVOID(ticalcs_free_lab_equipment_data2, NULL); PRINTF(ticalcs_calc_send_tigroup2, INT, NULL, (void *)0x12345678, -1); PRINTF(ticalcs_calc_send_tigroup2, INT, (void *)0x12345678, NULL, -1); PRINTF(ticalcs_calc_recv_tigroup2, INT, NULL, (void *)0x12345678, -1); @@ -697,6 +714,7 @@ static void torture_cmdz80(void) PRINTF(ti85_recv_RTS, INT, (void *)0x12345678, NULL, (void *)0x12345678, (void *)0x12345678); PRINTF(ti85_recv_RTS, INT, (void *)0x12345678, (void *)0x12345678, NULL, (void *)0x12345678); PRINTF(ti85_recv_RTS, INT, (void *)0x12345678, (void *)0x12345678, (void *)0x12345678, NULL); + PRINTF(tiz80_send_RTS_lab_equipment_data, INT, NULL, 0, 0, 0); } static void torture_cmd68k(void) @@ -705,6 +723,7 @@ static void torture_cmd68k(void) PRINTF(ti68k_model_to_dbus_mid, INT, CALC_NONE); PRINTF(ti68k_handle_to_dbus_mid, INT, NULL); PRINTF(ti89_send_VAR, INT, NULL, 0, 0, (void *)0x12345678); + PRINTF(ti68k_send_VAR_lab_equipment_data, INT, NULL, 0, 0, 0); PRINTF(ti89_send_CTS, INT, NULL); PRINTF(ti89_send_XDP, INT, NULL, 0, (void *)0x12345678); PRINTF(ti89_send_SKP, INT, NULL, 0); diff --git a/libticonv/trunk/src/ticonv.cc b/libticonv/trunk/src/ticonv.cc index 0d3b9efb1..02d858cf7 100644 --- a/libticonv/trunk/src/ticonv.cc +++ b/libticonv/trunk/src/ticonv.cc @@ -178,10 +178,15 @@ char* TICALL ticonv_charset_utf16_to_ti_s(CalcModel model, const unsigned short case CALC_TI73: return ticonv_utf16_to_ti73(utf16, ti); break; case CALC_TI80: return ticonv_utf16_to_ti80(utf16, ti); break; case CALC_TI82: return ticonv_utf16_to_ti82(utf16, ti); break; - case CALC_TI83: return ticonv_utf16_to_ti83(utf16, ti); break; + case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return ticonv_utf16_to_ti83(utf16, ti); break; case CALC_TI83P: case CALC_TI84P: - case CALC_TI84PC: return ticonv_utf16_to_ti83p(utf16, ti); break; + case CALC_TI84PC: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ticonv_utf16_to_ti83p(utf16, ti); break; case CALC_TI85: return ticonv_utf16_to_ti85(utf16, ti); break; case CALC_TI86: return ticonv_utf16_to_ti86(utf16, ti); break; case CALC_TI89: @@ -218,6 +223,7 @@ char* TICALL ticonv_charset_utf16_to_ti_s(CalcModel model, const unsigned short return ti; } break; + case CALC_TIPRESENTER: default: { ti[0] = 0; @@ -294,10 +300,15 @@ unsigned short* TICALL ticonv_charset_ti_to_utf16_s(CalcModel model, const char case CALC_TI73: return ticonv_ti73_to_utf16(ti, utf16); break; case CALC_TI80: return ticonv_ti80_to_utf16(ti, utf16); break; case CALC_TI82: return ticonv_ti82_to_utf16(ti, utf16); break; - case CALC_TI83: return ticonv_ti83_to_utf16(ti, utf16); break; + case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return ticonv_ti83_to_utf16(ti, utf16); break; case CALC_TI83P: case CALC_TI84P: - case CALC_TI84PC: return ticonv_ti83p_to_utf16(ti, utf16); break; + case CALC_TI84PC: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ticonv_ti83p_to_utf16(ti, utf16); break; case CALC_TI85: return ticonv_ti85_to_utf16(ti, utf16); break; case CALC_TI86: return ticonv_ti86_to_utf16(ti, utf16); break; case CALC_TI89: @@ -334,6 +345,7 @@ unsigned short* TICALL ticonv_charset_ti_to_utf16_s(CalcModel model, const char return utf16; } break; + case CALC_TIPRESENTER: default: utf16[0] = 0; return utf16; } } @@ -960,7 +972,13 @@ int TICALL ticonv_model_uses_utf8(CalcModel model) && model != CALC_TI92P && model != CALC_V200 && model != CALC_TI80 - && model != CALC_TI84PC); + && model != CALC_TI84PC + && model != CALC_CBL + && model != CALC_CBR + && model != CALC_CBL2 + && model != CALC_CBR2 + && model != CALC_LABPRO + && model != CALC_TIPRESENTER); } /** @@ -1038,6 +1056,25 @@ int TICALL ticonv_model_is_tinspire(CalcModel model) || (model >= CALC_NSPIRE_CRADLE && model <= CALC_NSPIRE_CXIIT_CAS))); } +/** + * ticonv_model_is_lab_equipment: + * @model: a calculator model taken in #CalcModel. + * + * Returns whether the given "calculator" model is a lab equipment. + * + * Return value: nonzero if the calculator is a lab equipment, zero if it doesn't. + */ +TIEXPORT4 int TICALL ticonv_model_is_lab_equipment(CalcModel model) +{ + return ( /*model < CALC_MAX + &&*/ ( model == CALC_NSPIRE_CRADLE + || model == CALC_CBL + || model == CALC_CBR + || model == CALC_CBL2 + || model == CALC_CBR2 + || model == CALC_LABPRO)); +} + /** * ticonv_model_has_legacy_ioport: * @model: a calculator model taken in #CalcModel. @@ -1062,7 +1099,12 @@ int TICALL ticonv_model_has_legacy_ioport(CalcModel model) || model == CALC_TI92P || model == CALC_V200 || model == CALC_TI80 - || model == CALC_TI84PC)); + || model == CALC_TI84PC + || model == CALC_CBL + || model == CALC_CBR + || model == CALC_CBL2 + || model == CALC_CBR2 + || model == CALC_LABPRO)); } /** @@ -1084,7 +1126,9 @@ int TICALL ticonv_model_has_usb_ioport(CalcModel model) || model == CALC_TI82A_USB || model == CALC_TI84PT_USB || model == CALC_TI82AEP_USB - || ticonv_model_is_tinspire(model))); + || ticonv_model_is_tinspire(model) + || model == CALC_CBR2 + || model == CALC_LABPRO)); // NOTE: the LabPro's USB port is B, not mini-B, and it's known to speak a protocol other than DUSB/CARS on that interface, at least in some conditions. } /** @@ -1106,7 +1150,10 @@ int TICALL ticonv_model_has_flash_memory(CalcModel model) && model != CALC_TI85 && model != CALC_TI86 && model != CALC_TI92 - && model != CALC_TI80); + && model != CALC_TI80 + && model != CALC_CBR + && model != CALC_CBL + && model != CALC_CBR2); // FIXME this might be wrong, but while we're aware of OS upgrades for CBL2, LabPro and TI-Presenter, we've never seen any for the CBR2. } /** @@ -1119,8 +1166,14 @@ int TICALL ticonv_model_has_flash_memory(CalcModel model) */ int TICALL ticonv_model_has_real_screen(CalcModel model) { - return ( /*model < CALC_MAX - &&*/ (model != CALC_NSPIRE_CRADLE)); + return ( model != CALC_NONE + && model < CALC_MAX + && model != CALC_NSPIRE_CRADLE + && model != CALC_CBL + && model != CALC_CBR + && model != CALC_CBL2 + && model != CALC_CBR2 + && model != CALC_LABPRO); } /** @@ -1155,7 +1208,8 @@ int TICALL ticonv_model_has_monochrome_screen(CalcModel model) || model == CALC_NSPIRE_CLICKPAD || model == CALC_NSPIRE_CLICKPAD_CAS || model == CALC_NSPIRE_TOUCHPAD - || model == CALC_NSPIRE_TOUCHPAD_CAS)); + || model == CALC_NSPIRE_TOUCHPAD_CAS + || model == CALC_TIPRESENTER)); } /** @@ -1226,6 +1280,12 @@ TIEXPORT4 CalcProductIDs TICALL ticonv_model_to_product_id(CalcModel model) case CALC_NSPIRE_CXII_CAS: return PRODUCT_ID_NSPIRE_CXII_CAS; case CALC_NSPIRE_CXIIT: return PRODUCT_ID_NSPIRE_CXIIT; case CALC_NSPIRE_CXIIT_CAS: return PRODUCT_ID_NSPIRE_CXII_CAS; + case CALC_CBL: return PRODUCT_ID_NONE; + case CALC_CBR: return PRODUCT_ID_NONE; + case CALC_CBL2: return PRODUCT_ID_CBL2; + case CALC_CBR2: return PRODUCT_ID_NONE; + case CALC_LABPRO: return PRODUCT_ID_LABPRO; + case CALC_TIPRESENTER: return PRODUCT_ID_TIPRESENTER; default: return PRODUCT_ID_NONE; } } diff --git a/libticonv/trunk/src/ticonv.h b/libticonv/trunk/src/ticonv.h index 0199e383a..efa46a9af 100644 --- a/libticonv/trunk/src/ticonv.h +++ b/libticonv/trunk/src/ticonv.h @@ -73,6 +73,7 @@ typedef enum CALC_NSPIRE_CX, CALC_NSPIRE_CX_CAS, CALC_NSPIRE_CMC, CALC_NSPIRE_CMC_CAS, // 31 CALC_NSPIRE_CXII, CALC_NSPIRE_CXII_CAS, CALC_NSPIRE_CXIIT, CALC_NSPIRE_CXIIT_CAS, // 35 CALC_TI82AEP_USB, // 36 + CALC_CBL, CALC_CBR, CALC_CBL2, CALC_CBR2, CALC_LABPRO, CALC_TIPRESENTER, // 42 CALC_MAX } CalcModel; @@ -180,6 +181,7 @@ typedef struct TIEXPORT4 int TICALL ticonv_model_is_tiez80(CalcModel model); TIEXPORT4 int TICALL ticonv_model_is_ti68k(CalcModel model); TIEXPORT4 int TICALL ticonv_model_is_tinspire(CalcModel model); + TIEXPORT4 int TICALL ticonv_model_is_lab_equipment(CalcModel model); TIEXPORT4 int TICALL ticonv_model_has_legacy_ioport(CalcModel model); TIEXPORT4 int TICALL ticonv_model_has_usb_ioport(CalcModel model); TIEXPORT4 int TICALL ticonv_model_has_flash_memory(CalcModel model); diff --git a/libticonv/trunk/src/tokens.cc b/libticonv/trunk/src/tokens.cc index bd9a770d4..a476cfdd0 100644 --- a/libticonv/trunk/src/tokens.cc +++ b/libticonv/trunk/src/tokens.cc @@ -509,6 +509,11 @@ char* TICALL ticonv_varname_detokenize(CalcModel model, const char *src, unsigne case CALC_TI83P: case CALC_TI84P: case CALC_TI84PC: + case CALC_CBL: // FIXME is that correct ? + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: dst = detokenize_vartype(model, src, type); if (dst) { @@ -552,6 +557,7 @@ char* TICALL ticonv_varname_detokenize(CalcModel model, const char *src, unsigne case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return g_strdup(src); + case CALC_TIPRESENTER: default: return g_strdup("________"); } diff --git a/libticonv/trunk/src/type2str.cc b/libticonv/trunk/src/type2str.cc index 2f2aead4c..f7894c047 100644 --- a/libticonv/trunk/src/type2str.cc +++ b/libticonv/trunk/src/type2str.cc @@ -74,6 +74,12 @@ const char * TICALL ticonv_model_to_string(CalcModel model) case CALC_NSPIRE_CXII_CAS: return "Nspire CX II CAS"; case CALC_NSPIRE_CXIIT: return "Nspire CX II-T"; case CALC_NSPIRE_CXIIT_CAS: return "Nspire CX II-T CAS"; + case CALC_CBL: return "CBL"; + case CALC_CBR: return "CBR"; + case CALC_CBL2: return "CBL2"; + case CALC_CBR2: return "CBR2"; + case CALC_LABPRO: return "LabPro"; + case CALC_TIPRESENTER: return "TI-Presenter"; default: return "unknown"; } } @@ -365,6 +371,39 @@ CalcModel TICALL ticonv_string_to_model(const char *str) || !g_ascii_strcasecmp(str, "CXIITCAS") ) return CALC_NSPIRE_CXIIT_CAS; + else if ( !g_ascii_strcasecmp(str, "TI-CBL") + || !g_ascii_strcasecmp(str, "TI CBL") + || !g_ascii_strcasecmp(str, "Vernier CBL") + || !g_ascii_strcasecmp(str, "CBL") + ) + return CALC_CBL; + else if ( !g_ascii_strcasecmp(str, "TI-CBR") + || !g_ascii_strcasecmp(str, "TI CBR") + || !g_ascii_strcasecmp(str, "Vernier CBR") + || !g_ascii_strcasecmp(str, "CBR") + ) + return CALC_CBR; + else if ( !g_ascii_strcasecmp(str, "TI-CBL2") + || !g_ascii_strcasecmp(str, "TI CBL2") + || !g_ascii_strcasecmp(str, "Vernier CBL2") + || !g_ascii_strcasecmp(str, "CBL2") + ) + return CALC_CBL2; + else if ( !g_ascii_strcasecmp(str, "TI-CBR2") + || !g_ascii_strcasecmp(str, "TI CBR2") + || !g_ascii_strcasecmp(str, "Vernier CBR2") + || !g_ascii_strcasecmp(str, "CBR2") + ) + return CALC_CBR2; + else if ( !g_ascii_strcasecmp(str, "Vernier LabPro") + || !g_ascii_strcasecmp(str, "LabPro") + ) + return CALC_LABPRO; + else if ( !g_ascii_strcasecmp(str, "TI-Presenter") + || !g_ascii_strcasecmp(str, "TI Presenter") + || !g_ascii_strcasecmp(str, "Presenter") + ) + return CALC_TIPRESENTER; } return CALC_NONE; diff --git a/libticonv/trunk/tests/torture_ticonv.c b/libticonv/trunk/tests/torture_ticonv.c index 28f63dc5f..6b295dd33 100644 --- a/libticonv/trunk/tests/torture_ticonv.c +++ b/libticonv/trunk/tests/torture_ticonv.c @@ -85,10 +85,11 @@ int main(int argc, char **argv) PRINTF(ticonv_model_is_tiez80, INT, CALC_NONE); PRINTF(ticonv_model_is_ti68k, INT, CALC_NONE); PRINTF(ticonv_model_is_tinspire, INT, CALC_NONE); + PRINTF(ticonv_model_is_lab_equipment, INT, CALC_NONE); PRINTF(ticonv_model_has_legacy_ioport, INT, CALC_NONE); PRINTF(ticonv_model_has_usb_ioport, INT, CALC_NONE); - PRINTF(ticonv_model_has_flash_memory, INT, CALC_NONE); + PRINTF(ticonv_model_has_flash_memory, INT, CALC_NONE); PRINTF(ticonv_model_has_real_screen, INT, CALC_NONE); PRINTF(ticonv_model_has_monochrome_screen, INT, CALC_NONE); PRINTF(ticonv_model_has_color_screen, INT, CALC_NONE); @@ -97,9 +98,9 @@ int main(int argc, char **argv) PRINTF(ticonv_varname_to_utf16_s, PTR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_to_utf16, PTR, -1, NULL, 0); PRINTF(ticonv_varname_to_utf8_sn, STR, -1, NULL, (void *)0x12345678, 0x12345678, 0); + PRINTF(ticonv_varname_to_utf8_sn, STR, -1, (void *)0x12345678, NULL, 0x12345678, 0); PRINTF(ticonv_varname_to_utf8_s, STR, -1, NULL, (void *)0x12345678, 0); - PRINTF(ticonv_varname_to_utf8_s, STR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_to_utf8, STR, -1, NULL, 0); PRINTF(ticonv_varname_to_filename_sn, STR, -1, NULL, (void *)0x12345678, 0x12345678, 0); @@ -108,9 +109,9 @@ int main(int argc, char **argv) PRINTF(ticonv_varname_to_filename_s, STR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_to_filename, STR, -1, NULL, 0); PRINTF(ticonv_varname_to_tifile_sn, STR, -1, NULL, (void *)0x12345678, 0x12345678, 0); + PRINTF(ticonv_varname_to_tifile_sn, STR, -1, (void *)0x12345678, NULL, 0x12345678, 0); PRINTF(ticonv_varname_to_tifile_s, STR, -1, NULL, (void *)0x12345678, 0); - PRINTF(ticonv_varname_to_tifile_s, STR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_to_tifile, STR, -1, NULL, 0); PRINTF(ticonv_varname_from_tifile_sn, STR, -1, NULL, (void *)0x12345678, 0x12345678, 0); @@ -119,9 +120,9 @@ int main(int argc, char **argv) PRINTF(ticonv_varname_from_tifile_s, STR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_from_tifile, STR, -1, NULL, 0); PRINTF(ticonv_model_to_string, STR, CALC_NONE); + PRINTF(ticonv_string_to_model, INT, NULL); fprintf(stderr, "%d\t%p\n", __LINE__, ti73_charset); - fprintf(stderr, "%d\t%p\n", __LINE__, ti80_charset); fprintf(stderr, "%d\t%p\n", __LINE__, ti82_charset); fprintf(stderr, "%d\t%p\n", __LINE__, ti83_charset); @@ -132,12 +133,12 @@ int main(int argc, char **argv) retval = ticonv_varname_detokenize(-1, NULL, 0); PRINTF(, STR, retval); ticonv_varname_free(retval); + retval = ticonv_varname_tokenize(-1, NULL, 0); PRINTF(, STR, retval); ticonv_varname_free(retval); PRINTFVOID(ticonv_varname_strdup, NULL); PRINTFVOID(ticonv_varname_free, NULL); - retval = ticonv_utf16_to_gfe(-1, NULL); PRINTF(, STR, retval); ticonv_gfe_free(retval); @@ -155,10 +156,10 @@ int main(int argc, char **argv) #endif ticonv_iconv, SIZE, ticonv_iconv_instance, NULL, NULL, NULL, NULL); PRINTF(ticonv_iconv_close, INT, ticonv_iconv_instance); + // charset.h PRINTF(ticonv_ti73_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti73_to_utf16, PTR, (void *)0x12345678, NULL); - PRINTF(ticonv_ti80_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti80_to_utf16, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_ti82_to_utf16, PTR, NULL, (void *)0x12345678); @@ -167,9 +168,9 @@ int main(int argc, char **argv) PRINTF(ticonv_ti83_to_utf16, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_ti83p_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti83p_to_utf16, PTR, (void *)0x12345678, NULL); + PRINTF(ticonv_ti85_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti85_to_utf16, PTR, (void *)0x12345678, NULL); - PRINTF(ticonv_ti86_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti86_to_utf16, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_ti9x_to_utf16, PTR, NULL, (void *)0x12345678); @@ -178,9 +179,9 @@ int main(int argc, char **argv) PRINTF(ticonv_utf16_to_ti73, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_utf16_to_ti80, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti80, PTR, (void *)0x12345678, NULL); + PRINTF(ticonv_utf16_to_ti82, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti82, PTR, (void *)0x12345678, NULL); - PRINTF(ticonv_utf16_to_ti83, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti83, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_utf16_to_ti83p, PTR, NULL, (void *)0x12345678); @@ -189,9 +190,9 @@ int main(int argc, char **argv) PRINTF(ticonv_utf16_to_ti85, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_utf16_to_ti86, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti86, PTR, (void *)0x12345678, NULL); + PRINTF(ticonv_utf16_to_ti9x, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti9x, PTR, (void *)0x12345678, NULL); - PRINTF(ticonv_ti84pusb_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti89tusb_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti84pusb, PTR, NULL, NULL); @@ -200,9 +201,9 @@ int main(int argc, char **argv) PRINTF(ticonv_ti84pusb_to_utf16, PTR, (void *)0x12345678, NULL); PRINTF(ticonv_ti89tusb_to_utf16, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_ti89tusb_to_utf16, PTR, (void *)0x12345678, NULL); + PRINTF(ticonv_utf16_to_ti84pusb, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti84pusb, PTR, (void *)0x12345678, NULL); - PRINTF(ticonv_utf16_to_ti89tusb, PTR, NULL, (void *)0x12345678); PRINTF(ticonv_utf16_to_ti89tusb, PTR, (void *)0x12345678, NULL); diff --git a/libtifiles/trunk/po/de.po b/libtifiles/trunk/po/de.po index a8c83a05e..8a098e19c 100644 --- a/libtifiles/trunk/po/de.po +++ b/libtifiles/trunk/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libtifiles2 1.1.8\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: 2019-10-29 14:15+0100\n" "Last-Translator: Andreas B. Mundt \n" "Language-Team: \n" @@ -110,20 +110,20 @@ msgstr "" "Grund: Das Programm, das diese Bibliothek benützt, ist\n" "Fehlerhaft. Kontaktieren Sie den Entwickler!" -#: src/filetypes.cc:1642 src/filetypes.cc:1766 src/types68k.cc:74 +#: src/filetypes.cc:1692 src/filetypes.cc:1816 src/types68k.cc:74 #: src/types83p.cc:70 src/typesoldz80.cc:75 msgid "OS upgrade" msgstr "Betriebssystem-Aktualisierung" -#: src/filetypes.cc:1653 src/filetypes.cc:1777 +#: src/filetypes.cc:1703 src/filetypes.cc:1827 msgid "TIGroup" msgstr "Tigroup" -#: src/filetypes.cc:1666 src/filetypes.cc:1790 +#: src/filetypes.cc:1716 src/filetypes.cc:1840 msgid "Group/Backup" msgstr "Gruppe/Backup" -#: src/filetypes.cc:1669 src/filetypes.cc:1793 +#: src/filetypes.cc:1719 src/filetypes.cc:1843 msgid "Group" msgstr "Gruppe" diff --git a/libtifiles/trunk/po/fr.po b/libtifiles/trunk/po/fr.po index fcb6eba69..77496e923 100644 --- a/libtifiles/trunk/po/fr.po +++ b/libtifiles/trunk/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libtifiles2 1.1.8\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: 2011-12-13 19:16+0100\n" "Last-Translator: Lionel Debroux \n" "Language-Team: Français \n" @@ -110,20 +110,20 @@ msgstr "" "Cause: le programme qui utilise cette librairie est buggé. Virez le " "développeur!" -#: src/filetypes.cc:1642 src/filetypes.cc:1766 src/types68k.cc:74 +#: src/filetypes.cc:1692 src/filetypes.cc:1816 src/types68k.cc:74 #: src/types83p.cc:70 src/typesoldz80.cc:75 msgid "OS upgrade" msgstr "maj OS" -#: src/filetypes.cc:1653 src/filetypes.cc:1777 +#: src/filetypes.cc:1703 src/filetypes.cc:1827 msgid "TIGroup" msgstr "TIGroup" -#: src/filetypes.cc:1666 src/filetypes.cc:1790 +#: src/filetypes.cc:1716 src/filetypes.cc:1840 msgid "Group/Backup" msgstr "Groupe/sauvegarde" -#: src/filetypes.cc:1669 src/filetypes.cc:1793 +#: src/filetypes.cc:1719 src/filetypes.cc:1843 msgid "Group" msgstr "Groupe" diff --git a/libtifiles/trunk/po/libtifiles2.pot b/libtifiles/trunk/po/libtifiles2.pot index 72a60405b..2497c7e18 100644 --- a/libtifiles/trunk/po/libtifiles2.pot +++ b/libtifiles/trunk/po/libtifiles2.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libtifiles2 1.1.8\n" "Report-Msgid-Bugs-To: tilp-users@lists.sourceforge.net\n" -"POT-Creation-Date: 2023-09-13 22:08+0200\n" +"POT-Creation-Date: 2023-09-13 22:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -102,20 +102,20 @@ msgid "" "Cause: the program which uses this library is buggy. Fire-up the developer!" msgstr "" -#: src/filetypes.cc:1642 src/filetypes.cc:1766 src/types68k.cc:74 +#: src/filetypes.cc:1692 src/filetypes.cc:1816 src/types68k.cc:74 #: src/types83p.cc:70 src/typesoldz80.cc:75 msgid "OS upgrade" msgstr "" -#: src/filetypes.cc:1653 src/filetypes.cc:1777 +#: src/filetypes.cc:1703 src/filetypes.cc:1827 msgid "TIGroup" msgstr "" -#: src/filetypes.cc:1666 src/filetypes.cc:1790 +#: src/filetypes.cc:1716 src/filetypes.cc:1840 msgid "Group/Backup" msgstr "" -#: src/filetypes.cc:1669 src/filetypes.cc:1793 +#: src/filetypes.cc:1719 src/filetypes.cc:1843 msgid "Group" msgstr "" diff --git a/libtifiles/trunk/src/filetypes.cc b/libtifiles/trunk/src/filetypes.cc index 42afbd125..2489a4e5d 100644 --- a/libtifiles/trunk/src/filetypes.cc +++ b/libtifiles/trunk/src/filetypes.cc @@ -51,6 +51,7 @@ static const char GROUP_FILE_EXT[CALC_MAX + 1][4] = "", "", "", "", // 31 "", "", "", "", // 35 "8xg", // 36 + "", "", "", "", "", "", // 42 "" }; @@ -66,6 +67,7 @@ static const char BACKUP_FILE_EXT[CALC_MAX + 1][4] = "", "", "", "", // 31 "", "", "", "", // 35 "8Xb", // 36 + "", "", "", "", "", "", // 42 "" }; @@ -138,6 +140,12 @@ const char * TICALL tifiles_fext_of_group (CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: return NULL; default: tifiles_critical("%s: invalid model argument", __FUNCTION__); @@ -214,6 +222,12 @@ const char * TICALL tifiles_fext_of_backup (CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: return NULL; default: tifiles_critical("%s: invalid model argument", __FUNCTION__); @@ -292,6 +306,12 @@ const char * TICALL tifiles_fext_of_flash_app (CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: return NULL; default: tifiles_critical("%s: invalid model argument", __FUNCTION__); @@ -385,6 +405,15 @@ const char * TICALL tifiles_fext_of_flash_os(CalcModel model) return "tct2"; case CALC_NSPIRE_CXIIT_CAS: return "tcc2"; + case CALC_CBL: + case CALC_CBR: + case CALC_CBR2: + return NULL; + case CALC_CBL2: + case CALC_LABPRO: + return "c2u"; // .hex is also seen in some OS upgraders. + case CALC_TIPRESENTER: + return "hex"; // Sbase132.hex from the Windows TI-Presenter OS upgrader. default: tifiles_critical("%s: invalid model argument", __FUNCTION__); break; @@ -462,6 +491,12 @@ const char * TICALL tifiles_fext_of_certif(CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: return NULL; default: tifiles_critical("%s: invalid calc_type argument", __FUNCTION__); @@ -559,7 +594,7 @@ int TICALL tifiles_file_has_ti_header(const char *filename) !strcmp(buf, "**TI85**") || !strcmp(buf, "**TI86**") || !strcmp(buf, "**TI89**") || !strcmp(buf, "**TI92**") || !strcmp(buf, "**TI92P*") || !strcmp(buf, "**V200**") || - !strcmp(buf, "**TIFL**") || + !strcmp(buf, "**TIFL**") || !strcmp(buf, "**TICBL*") || !strncmp(buf, "*TI", 3)) { ret = !0; @@ -855,6 +890,11 @@ int TICALL tifiles_model_to_dev_type(CalcModel model) case CALC_V200: return DEVICE_TYPE_92P; #endif + case CALC_CBL2: + case CALC_LABPRO: + return DEVICE_TYPE_CBL2; + case CALC_TIPRESENTER: + return DEVICE_TYPE_TIPRESENTER; default: return -1; } @@ -1557,6 +1597,16 @@ CalcModel TICALL tifiles_fext_to_model(const char *ext) // else fall through. } #endif + else if (c1 == 'c' && c2 == '2' && c3 == 'u') + { + // Or CALC_LABPRO, but we can't distinguish them at a file extension level, and the same OS upgrades work on both models. + type = CALC_CBL2; + } + else if (c1 == 'h' && c2 == 'e' && c3 == 'x') + { + // Might be a file suitable for the TI-Presenter, but some versions of the CBL2 OS upgraders contain hex files as well. + type = CALC_TIPRESENTER; + } // else fall through. } @@ -1631,7 +1681,7 @@ const char *TICALL tifiles_file_get_type(const char *filename) return ""; } - if ( !g_ascii_strcasecmp(e, "tib") + if ( !g_ascii_strcasecmp(e, "tib") || !g_ascii_strcasecmp(e, "c2u") || !g_ascii_strcasecmp(e, "tno") || !g_ascii_strcasecmp(e, "tnc") || !g_ascii_strcasecmp(e, "tco") || !g_ascii_strcasecmp(e, "tcc") || !g_ascii_strcasecmp(e, "tco2") || !g_ascii_strcasecmp(e, "tcc2") diff --git a/libtifiles/trunk/src/tifiles.h b/libtifiles/trunk/src/tifiles.h index 2d7c2633f..d006db52a 100644 --- a/libtifiles/trunk/src/tifiles.h +++ b/libtifiles/trunk/src/tifiles.h @@ -103,6 +103,8 @@ typedef enum DEVICE_TYPE_73 = 0x74, DEVICE_TYPE_89 = 0x98, DEVICE_TYPE_92P = 0x88, + DEVICE_TYPE_CBL2 = 0x42, // Also LabPro + DEVICE_TYPE_TIPRESENTER = 0x43, } DeviceType; /* Structures (common to all calcs) */ diff --git a/libtifiles/trunk/src/typesxx.cc b/libtifiles/trunk/src/typesxx.cc index 1ea124944..0d7da22c2 100644 --- a/libtifiles/trunk/src/typesxx.cc +++ b/libtifiles/trunk/src/typesxx.cc @@ -53,8 +53,13 @@ const char *TICALL tifiles_vartype2string(CalcModel model, uint8_t data) case CALC_TI82: return tixx_byte2type(TI82_CONST, TI82_MAXTYPES, data); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_byte2type(TI83_CONST, TI83_MAXTYPES, data); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_byte2type(data); case CALC_TI84P: case CALC_TI84P_USB: @@ -105,6 +110,7 @@ const char *TICALL tifiles_vartype2string(CalcModel model, uint8_t data) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_byte2type(NSP_CONST, NSP_MAXTYPES, data); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return ""; @@ -136,8 +142,13 @@ uint8_t TICALL tifiles_string2vartype(CalcModel model, const char *s) case CALC_TI82: return tixx_type2byte(TI82_CONST, TI82_MAXTYPES, s); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_type2byte(TI83_CONST, TI83_MAXTYPES, s); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_type2byte(s); case CALC_TI84P: case CALC_TI84P_USB: @@ -188,6 +199,7 @@ uint8_t TICALL tifiles_string2vartype(CalcModel model, const char *s) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_type2byte(NSP_CONST, NSP_MAXTYPES, s); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return 0; @@ -213,8 +225,13 @@ const char *TICALL tifiles_vartype2fext(CalcModel model, uint8_t data) case CALC_TI82: return tixx_byte2fext(TI82_CONST, TI82_MAXTYPES, data, "82?"); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_byte2fext(TI83_CONST, TI83_MAXTYPES, data, "83?"); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_byte2fext(data); case CALC_TI84P: case CALC_TI84P_USB: @@ -265,6 +282,7 @@ const char *TICALL tifiles_vartype2fext(CalcModel model, uint8_t data) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_byte2fext(NSP_CONST, NSP_MAXTYPES, data, "tn?"); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return ""; @@ -296,8 +314,13 @@ uint8_t TICALL tifiles_fext2vartype(CalcModel model, const char *s) case CALC_TI82: return tixx_fext2byte(TI82_CONST, TI82_MAXTYPES, s); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_fext2byte(TI83_CONST, TI83_MAXTYPES, s); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_fext2byte(s); case CALC_TI84P: case CALC_TI84P_USB: @@ -348,6 +371,7 @@ uint8_t TICALL tifiles_fext2vartype(CalcModel model, const char *s) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_fext2byte(NSP_CONST, NSP_MAXTYPES, s); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return 0; @@ -374,8 +398,13 @@ const char *TICALL tifiles_vartype2type(CalcModel model, uint8_t vartype) case CALC_TI82: return tixx_byte2desc(TI82_CONST, TI82_MAXTYPES, vartype); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_byte2desc(TI83_CONST, TI83_MAXTYPES, vartype); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_byte2desc(vartype); case CALC_TI84P: case CALC_TI84P_USB: @@ -426,6 +455,7 @@ const char *TICALL tifiles_vartype2type(CalcModel model, uint8_t vartype) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_byte2desc(NSP_CONST, NSP_MAXTYPES, vartype); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return ""; @@ -452,8 +482,13 @@ const char *TICALL tifiles_vartype2icon(CalcModel model, uint8_t vartype) case CALC_TI82: return tixx_byte2icon(TI82_CONST, TI82_MAXTYPES, vartype); case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return tixx_byte2icon(TI83_CONST, TI83_MAXTYPES, vartype); case CALC_TI83P: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return ti83p_byte2icon(vartype); case CALC_TI84P: case CALC_TI84P_USB: @@ -504,6 +539,7 @@ const char *TICALL tifiles_vartype2icon(CalcModel model, uint8_t vartype) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return tixx_byte2icon(NSP_CONST, NSP_MAXTYPES, vartype); + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); return ""; @@ -536,6 +572,8 @@ uint8_t TICALL tifiles_folder_type(CalcModel model) case CALC_TI82: return -1; case CALC_TI83: + case CALC_CBL: + case CALC_CBR: return TI83_DIR; case CALC_TI83P: case CALC_TI84P: @@ -547,6 +585,9 @@ uint8_t TICALL tifiles_folder_type(CalcModel model) case CALC_TI82A_USB: case CALC_TI84PT_USB: case CALC_TI82AEP_USB: + case CALC_CBL2: // Dubious + case CALC_CBR2: // Dubious + case CALC_LABPRO: // Dubious return TI83p_DIR; case CALC_TI85: return -1; @@ -580,6 +621,7 @@ uint8_t TICALL tifiles_folder_type(CalcModel model) case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return NSP_DIR; + case CALC_TIPRESENTER: default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); break; @@ -610,6 +652,11 @@ uint8_t TICALL tifiles_flash_type(CalcModel model) case CALC_TI82: return -1; case CALC_TI83: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return -1; case CALC_TI83P: case CALC_TI84P: @@ -654,6 +701,7 @@ uint8_t TICALL tifiles_flash_type(CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_TIPRESENTER: return -1; default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); @@ -685,6 +733,11 @@ uint8_t TICALL tifiles_idlist_type(CalcModel model) case CALC_TI82: return -1; case CALC_TI83: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: return -1; case CALC_TI83P: case CALC_TI84P: @@ -728,6 +781,7 @@ uint8_t TICALL tifiles_idlist_type(CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_TIPRESENTER: return -1; default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); @@ -762,6 +816,8 @@ const char *TICALL tifiles_calctype2signature(CalcModel model) case CALC_TI82: return "**TI82**"; case CALC_TI83: + case CALC_CBL: // Dubious + case CALC_CBR: // Dubious return "**TI83**"; case CALC_TI83P: case CALC_TI84P: @@ -773,6 +829,9 @@ const char *TICALL tifiles_calctype2signature(CalcModel model) case CALC_TI82A_USB: case CALC_TI84PT_USB: case CALC_TI82AEP_USB: + case CALC_CBL2: // Dubious + case CALC_CBR2: // Dubious + case CALC_LABPRO: // Dubious return "**TI83F*"; case CALC_TI85: return "**TI85**"; @@ -805,6 +864,7 @@ const char *TICALL tifiles_calctype2signature(CalcModel model) case CALC_NSPIRE_CXII_CAS: case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: + case CALC_TIPRESENTER: return ""; default: tifiles_critical("%s: invalid model argument.", __FUNCTION__); @@ -846,6 +906,8 @@ CalcModel TICALL tifiles_signature2calctype(const char *s) return CALC_TI92P; else if (!g_ascii_strcasecmp(s, "**V200**")) return CALC_V200; + else if (!g_ascii_strcasecmp(s, "**TICBL*")) + return CALC_CBL2; } tifiles_critical("%s: invalid signature.", __FUNCTION__); return CALC_NONE;