Register

Protocol 7.00 - Slowness and solutions

Discuss issues related to Calculator Hacking/Modding.
Senior Member
User avatar
Posts: 101
Joined: Sun Mar 27, 2016 10:24 am
Location: France
Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50

Protocol 7.00 - Slowness and solutions

Postby cakeisalie5 » Fri Sep 02, 2016 8:41 am

Hello,

I have finished my CLI software to transfer files in and out the calculator, called P7 (using libp7, only available on GNU/Linux for now), one week ago, and it works fine, but I'm working on solutions to make it quicker, and as I don't know much more on protocol 7.00 than what I have found in the fxReverse projet documentation (the basics), I came here to ask if some more techniques had been found.

I'll take the simple file sending example (the file request is more tricky). For a normal packet flow (check[ini], ack, command, ack, {data, ack}, term, ack), the calculator takes ~30ms to answer each data packet. I have found out on the older transfer software (called "UsbConnector" and made by Nessotrin, part of the Planète Casio community) that he uses a special technique to make file sending quicker : he sends two initial check packets and only answers one. I have spontaneously called this technique "packet shifting" and it looks pretty dangerous (he always sends an overwrite, so he doesn't care, but as I use the protocol part about overwrite confirmation to interactively ask to the user if he wants to overwrite...), and my (few) tests didn't succeed in shifting packets other than initial check packets (which means I cannot disable it for interactive parts of the protocol then enable it for data transfer). And I haven't yet thought about how packet shifting could apply for file requesting (roleswap makes it tricky)... but results are here : the calculator takes ~3ms to answer, 10 times less.

Also, I've been told by someone using P7 (the software) that it sometimes goes really fast for him too (not always), but I've never experienced this speed increasing in my experiments. So I'm here seeking for ideas about how I could speed up the transmission (make the calculator answer faster), if someone knows a little more about packet shifting (Nessotrin didn't answer yet, but he might have gotten that idea from somewhere else), or some other techniques.

Thanks in advance :)

(simple log sending a 2K-large random file : )
Logs: Show
Code: Select all
[libp7 info]  p7_init: creating libusb context
[libp7 info]  p7_init: checking for the calculator
[libp7 info]  p7_init: getting the device handler
[libp7 info]  p7_start: sending initial check
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  0530 3030 3730                          .00070
[libp7 info]  p7_send_basic: packet sent, sending took 246µs
[libp7 info]  p7_recv_main: it took 0µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 21695µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_start: checking check answer
[libp7 info]  p7_sendfile: calculating given file size
[libp7 info]  p7_sendfile: filesize is 2048o
[libp7 info]  p7_sendstream: sending file transfer command
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0134 3531 3030 3233 3032 3030 3030 3030 .451002302000000
[libp7 info]  3038 3030 3030 3037 3030 3030 3034 3030 0800000700000400
[libp7 info]  7969 7069 7961 7966 6C73 3038 39        yipiyayfls089
[libp7 info]  p7_send_ext: packet sent, sending took 407µs
[libp7 info]  p7_recv_main: it took 539µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 42221µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: checking file transfer answer
[libp7 info]  p7_sendstream: about to send 8 packets
[libp7 info]  p7_sendstream: last one is irregular and contains 256o
[libp7 info]  p7_sendstream: sending packet 1/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3239 3030 3038 3030 3031 .451012900080001
[libp7 info]  8E3F 785C 3365 8AE3 625C 26D7 BD3D CCC4 .?x\3e..b\&..=..
[libp7 info]  78DE 7DCD 865C 23E0 7D5C 39E1 7A5C 33E0 x.}..\#.}\9.z\3.
[libp7 info]  50B1 8E4D 277D AC67 5C3A 265D 2FB8 5C24 P..M'}.g\:&]/.\$
[libp7 info]  D7DD E055 7AF8 A347 D35F 29A5 DAE6 DD2E ...Uz..G._).....
[libp7 info]  D3E1 43FE 5C30 2D90 2B5C 2E4F 6052 4696 ..C.\0-.+\.O`RF.
[libp7 info]  BD89 C169 495B 42D3 9726 4373 FB42 CBAF ...iI[B..&Cs.B..
[libp7 info]  F0DE 80AD 52F5 5A5C 3AF7 4AC8 2A3B 5C36 ....R.Z\:.J.*;\6
[libp7 info]  742B 5C38 8C43 CB26 E996 4968 8DF8 C076 t+\8.C.&..Ih...v
[libp7 info]  57A0 3ABD 6FF4 D541 A2C0 9F8A 89A5 208F W.:.o..A...... .
[libp7 info]  5F5C 38FE 58C5 E0BA 535C 20E8 A05A D06F _\8.X...S\ ..Z.o
[libp7 info]  A75C 2832 5C34 A3E4 8B6C 2A22 96C9 2175 .\(2\4...l*"..!u
[libp7 info]  6E5C 2574 944D 3C7A 8233 E45C 2F5C 359E n\%t.M<z.3.\/\5.
[libp7 info]  5398 E3BA 32CB 356F 955C 3681 C2EA 5C3C S...2.5o.\6...\<
[libp7 info]  95E2 6B37 7AD6 894B 3BAF 3E5C 2060 7367 ..k7z..K;.>\ `sg
[libp7 info]  875C 3C4F 5C31 5C23 645C 2A21 AFB7 F574 .\<O\1\#d\*!...t
[libp7 info]  C15C 3A5C 20CC B4D1 B685 A6F0 72AF 4366 .\:\ .......r.Cf
[libp7 info]  8297 5C21 E86C E4AE D5AB 5C2B 5C34 86F3 ..\!.l....\+\4..
[libp7 info]  5C21 256D 29D7 4A5C 2D46 44BE 696F D9A7 \!%m).J\-FD.io..
[libp7 info]  5A36 34                                 Z64
[libp7 info]  p7_send_ext: packet sent, sending took 1477µs
[libp7 info]  p7_recv_main: it took 1809µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 6423µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 2/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3143 3030 3038 3030 3032 .451011C00080002
[libp7 info]  CBF1 3C58 5C3B C738 78A0 AC65 3665 8831 ..<X\;.8x..e6e.1
[libp7 info]  5C38 F6F1 F7B6 26BE 69F8 9C4D BD89 C182 \8....&.i..M....
[libp7 info]  FBF8 2FBF FB5C 2C3B 49A7 CC45 99CE 9973 ../..\,;I..E...s
[libp7 info]  878C B5C4 5A5C 2A6B 8C46 9A88 8941 7E5C ....Z\*k.F...A~\
[libp7 info]  39C5 4E58 E18B 344A 90F4 FED6 2469 B472 9.NX..4J....$i.r
[libp7 info]  E18D 894A 5C2B 4CA8 9F7D B25C 36D6 A65C ...J\+L..}.\6..\
[libp7 info]  2883 9B66 43C8 7F6C 4E5A BAE0 E13A BA24 (..fC..lNZ...:.$
[libp7 info]  B75C 23FC AA9C B861 FA3D E75C 24C6 5863 .\#....a.=.\$.Xc
[libp7 info]  EF96 554F 8335 7DA7 7B54 DC54 5C37 D491 ..UO.5}.{T.T\7..
[libp7 info]  C4C6 2B5C 396D 884F 3157 5BE0 FC5D 9F5F ..+\9m.O1W[..]._
[libp7 info]  7C65 308C A9EC 3073 FE85 D545 2C94 DE2C |e0...0s...E,..,
[libp7 info]  8177 38F5 3642 80A8 CC3C BB21 5A97 6D5C .w8.6B...<.!Z.m\
[libp7 info]  3364 8658 3E25 9EA2 775C 3BFE 5C34 E549 3d.X>%..w\;.\4.I
[libp7 info]  937C 3BA7 5C5C 3F5C 20C1 C650 D65D EB90 .|;.\\?\ ..P.]..
[libp7 info]  2BE4 AFD1 6521 6CC3 5C33 4467 AA22 33DF +...e!l.\3Dg."3.
[libp7 info]  B5E5 2AA3 39C9 25D4 2DF7 5C34 AFA6 5C25 ..*.9.%.-.\4..\%
[libp7 info]  619F A244 D04B ECC4 C23A 7570 8659 70C7 a..D.K...:up.Yp.
[libp7 info]  B2B1 49FA 3835                          ..I.85
[libp7 info]  p7_send_ext: packet sent, sending took 1171µs
[libp7 info]  p7_recv_main: it took 1324µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27591µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 3/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3241 3030 3038 3030 3033 .451012A00080003
[libp7 info]  B483 B4AF 88A6 7F61 5C3C C54C FB53 B25C .......a\<.L.S.\
[libp7 info]  2C3F DCB0 4B30 AC5C 25F7 9F5C 345B 5C3F ,?..K0.\%..\4[\?
[libp7 info]  E8AA DF95 8A85 FC73 36C6 F45C 28DC 295C .......s6..\(.)\
[libp7 info]  31DA 21EE 275C 2DDD A4CB 5C2A 5C34 E6F0 1.!.'\-...\*\4..
[libp7 info]  5C2A 426D 4E2D E9F9 4B75 B835 5B7D 20EC \*BmN-..Ku.5[} .
[libp7 info]  2DB7 F6A4 C5BC B143 7A5C 5C39 DD27 8957 -......Cz\\9.'.W
[libp7 info]  9672 9584 7AAB 6D7D 2A7C 812B 9329 B327 .r..z.m}*|.+.).'
[libp7 info]  F95C 5C44 BD6B 4ABF 7D72 BD5C 2A87 C36F .\\D.kJ.}r.\*..o
[libp7 info]  C1DE 7E8B D25C 315C 2DCA 5C20 6823 B85C ..~..\1\-.\ h#.\
[libp7 info]  215C 366B D65C 2A9B B9B1 92F1 2E43 4C21 !\6k.\*......CL!
[libp7 info]  E872 49CB 5126 A07F 5C27 7274 6BCC D340 .rI.Q&..\'rtk..@
[libp7 info]  F49B 855C 2D80 CD5C 3E5C 30D2 358B 9BF0 ...\-..\>\0.5...
[libp7 info]  4282 C75C 29AD C652 F35C 5CCE 46C3 24C7 B..\)..R.\\.F.$.
[libp7 info]  632D 49F3 9B88 DEA3 CC5C 265F 3D7B 3961 c-I......\&_={9a
[libp7 info]  9E4F 3B8F C55C 5C86 FD8E 5C2A C978 7EED .O;..\\...\*.x~.
[libp7 info]  2CD3 FED5 DBA3 C5FE A193 6FAC B19D D4A8 ,.........o.....
[libp7 info]  E9D9 5C2F 3AEA A278 C35F 2DEE 5C27 76A7 ..\/:..x._-.\'v.
[libp7 info]  27A0 6CE7 5C2E 5C29 27E0 B890 475C 3C5F '.l.\.\)'...G\<_
[libp7 info]  B759 4642                               .YFB
[libp7 info]  p7_send_ext: packet sent, sending took 1439µs
[libp7 info]  p7_recv_main: it took 1671µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27053µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 4/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3241 3030 3038 3030 3034 .451012A00080004
[libp7 info]  5C34 3E81 344F F488 6E5B 468B C4FC 5C5C \4>.4O..n[F...\\
[libp7 info]  5C23 5C2B 6CCC 615C 3FF7 EF72 61C6 9D89 \#\+l.a\?..ra...
[libp7 info]  A250 5C5C 645C 3A5C 3EA0 C95C 2CC8 96A6 .P\\d\:\>..\,...
[libp7 info]  7DD9 965D 3E45 5FF9 246D EBCE 5C3F E071 }..]>E_.$m..\?.q
[libp7 info]  E0A0 5473 BF5C 3ABB DFE5 42A7 2AB3 82B7 ..Ts.\:...B.*...
[libp7 info]  463F D583 5C24 2ECE 5C3C AFC4 6956 FC4C F?..\$..\<..iV.L
[libp7 info]  5C34 6F53 225C 3CB5 D637 67E9 489E 2F3F \4oS"\<..7g.H./?
[libp7 info]  3D5C 2A9E CE42 CAEF B8B1 8C8B 35DD 415D =\*..B......5.A]
[libp7 info]  63C4 7960 699B 22F3 AD3A 3B5C 2DE8 B5DD c.y`i."..:;\-...
[libp7 info]  C1BD 56FD 7C49 28A1 9C97 9722 34FA B2EF ..V.|I(...."4...
[libp7 info]  5C32 F85C 31AF B833 242F E297 5C20 5C3E \2.\1..3$/..\ \>
[libp7 info]  F1B2 8BEF 67E6 5C28 3AF7 B05C 3A43 5045 ....g.\(:..\:CPE
[libp7 info]  D082 D1B1 994B A3DC 5C28 5C2D 609B 5C37 .....K..\(\-`.\7
[libp7 info]  6080 8D5C 32A0 23A0 AD70 E526 846F 2C80 `..\2.#..p.&.o,.
[libp7 info]  DC28 CB42 48F7 9899 69CD 975C 386A 31E7 .(.BH...i..\8j1.
[libp7 info]  29AB DA5C 2EE4 CDDD 75B2 753F F9D6 C9D5 )..\....u.u?....
[libp7 info]  25CD CA5C 306C C5D2 68CA 5C25 3637 A55C %..\0l..h.\%67.\
[libp7 info]  3970 FC5C 2B5C 344C AA78 6AC2 E26E 2CCA 9p.\+\4L.xj..n,.
[libp7 info]  647A 3736                               dz76
[libp7 info]  p7_send_ext: packet sent, sending took 1086µs
[libp7 info]  p7_recv_main: it took 1318µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27449µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 5/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3239 3030 3038 3030 3035 .451012900080005
[libp7 info]  7FA3 6C5C 2FEA 5C3C 5C3A FF5C 247F 62D0 ..l\/.\<\:.\$.b.
[libp7 info]  29EA E9EC 2CF9 5C3F CCEF 86CA DC5C 2AA8 )...,.\?.....\*.
[libp7 info]  89D9 F75F D2D1 4498 735C 3A55 5C20 3064 ..._..D.s\:U\ 0d
[libp7 info]  275C 2B3F 8197 33CC 5C2F B95C 3AFC 38E4 '\+?..3.\/.\:.8.
[libp7 info]  E5C5 8F66 B777 FDBF CA32 5C25 A3D6 83AC ...f.w...2\%....
[libp7 info]  4B8D A3D2 B5FF 5C3B 5B32 5C5C F02A 5C25 K.....\;[2\\.*\%
[libp7 info]  94BA 768A 6F5A 3228 6831 D2EC 7323 30BB ..v.oZ2(h1..s#0.
[libp7 info]  205C 2ECD FB36 B546 49BE F2D4 6E7D 3995  \...6.FI...n}9.
[libp7 info]  285C 255C 3189 945C 3836 4238 E559 EEC9 (\%\1..\86B8.Y..
[libp7 info]  245C 2590 E728 B3F1 FC5F 3F97 56C2 345C $\%..(..._?.V.4\
[libp7 info]  3FC1 3C47 D46A 852B 4BD8 5C34 6F5C 2B5C ?.<G.j.+K.\4o\+\
[libp7 info]  2B47 E6C5 D6B2 B577 7B5C 2179 C47A EDB6 +G.....w{\!y.z..
[libp7 info]  ACF0 6B7E 5C39 305C 2D8F 9881 9F89 C04D ..k~\90\-......M
[libp7 info]  F570 785C 329F 5C2E C5F3 C33E FEFC 4C8F .px\2.\....>..L.
[libp7 info]  5C21 D5D5 8894 EC71 2B37 D73C 5C22 FAB6 \!.....q+7.<\"..
[libp7 info]  76B9 5C3A A778 B16B B243 A490 3D2A DDF3 v.\:.x.k.C..=*..
[libp7 info]  DC54 7161 5DEF 60E2 8346 5C32 5266 D2E2 .Tqa].`..F\2Rf..
[libp7 info]  20C1 FA35 375F C1C9 6F67 B04D 97F9 FA83  ..57_..og.M....
[libp7 info]  9736 37                                 .67
[libp7 info]  p7_send_ext: packet sent, sending took 1318µs
[libp7 info]  p7_recv_main: it took 1545µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27304µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 6/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3245 3030 3038 3030 3036 .451012E00080006
[libp7 info]  5C28 A5AD F2B8 CF23 5C25 FC87 5C28 8E3F \(.....#\%..\(.?
[libp7 info]  5C30 617E 5C38 5C25 6E60 A956 5C3D 5C2B \0a~\8\%n`.V\=\+
[libp7 info]  85E9 8D3C FA65 5C38 6C77 9072 EF51 F1FE ...<.e\8lw.r.Q..
[libp7 info]  7CA9 6CD4 AB3B 69E1 3DDE 3CFA 535C 2ADC |.l..;i.=.<.S\*.
[libp7 info]  F9B4 B39F 5C30 B923 2435 3FF0 9A3B 7A5C ....\0.#$5?..;z\
[libp7 info]  3F69 EDBA 605C 2449 6628 5C28 C4BA CA5C ?i..`\$If(\(...\
[libp7 info]  277D C4DA 5C3D 6129 785C 315C 3FD2 9B53 '}..\=a)x\1\?..S
[libp7 info]  5C5C EB5C 3337 9443 C176 5021 BEF6 315C \\.\37.C.vP!..1\
[libp7 info]  22E3 855C 308A 635D F9E5 D5D4 5C37 DE28 "..\0.c]....\7.(
[libp7 info]  7BAE CEAE A5E8 C1EE AD21 71C4 DA66 23BC {........!q..f#.
[libp7 info]  39E6 3C7D 25AE 4AE0 4BB6 F57F 2AE0 DB96 9.<}%.J.K...*...
[libp7 info]  2D6F D45C 2BF8 88C2 B0CB 5C20 86A1 A46C -o.\+.....\ ...l
[libp7 info]  A228 E84F 2355 F0F0 5C3B 5C33 B54E F2F3 .(.O#U..\;\3.N..
[libp7 info]  385C 22A3 86D0 2348 935C 3D96 3240 B55B 8\"...#H.\=.2@.[
[libp7 info]  B82B E796 22AB E95C 32DB 9051 469D 9190 .+.."..\2..QF...
[libp7 info]  CFFC 364E 785C 2D97 5C21 5D25 D4D6 4751 ..6Nx\-.\!]%..GQ
[libp7 info]  C49D 6B5C 31C3 D062 555C 216F F197 81F2 ..k\1..bU\!o....
[libp7 info]  F495 8DE6 5C30 C6FD E024 7F6B 5C3C B35C ....\0...$.k\<.\
[libp7 info]  3B2A 5C2A 21B5 3132                     ;*\*!.12
[libp7 info]  p7_send_ext: packet sent, sending took 1312µs
[libp7 info]  p7_recv_main: it took 1507µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27214µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 7/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3335 3030 3038 3030 3037 .451013500080007
[libp7 info]  643D EB5C 3E6E 5C2D 6FBF A328 B146 5C3F d=.\>n\-o..(.F\?
[libp7 info]  5C3C C37B 918B A169 FEB6 44F2 5C38 5837 \<.{...i..D.\8X7
[libp7 info]  B95E 75F6 CC5C 3FFA 2FCB AFF2 E7AE B35B .^u..\?./......[
[libp7 info]  FE98 5C26 C45C 265C 5CDA D1B3 5C20 E2DA ..\&.\&\\...\ ..
[libp7 info]  4353 2B22 5B72 A32D A296 5C3B C051 5C2F CS+"[r.-..\;.Q\/
[libp7 info]  B529 4581 7ECA C5D7 9770 44B8 D13F 5C21 .)E.~....pD..?\!
[libp7 info]  966A 9C39 446A 5C39 603F E075 422E 34EE .j.9Dj\9`?.uB.4.
[libp7 info]  635C 36C3 5C23 CD8B 5C2A C9DC DE2D 4086 c\6.\#..\*...-@.
[libp7 info]  5C26 5C34 3D5E 5C2A A02B F484 3661 F3EB \&\4=^\*.+..6a..
[libp7 info]  F65C 28F1 5C35 9830 F8ED 6B90 9A5C 3585 .\(.\5.0..k..\5.
[libp7 info]  817D 6BAF F45C 2FB4 3F78 2D98 A65C 23A5 .}k..\/.?x-..\#.
[libp7 info]  464C 5C2B DF2B 5DE2 8CD0 5C22 B9C6 DABA FL\+.+]...\"....
[libp7 info]  5C26 6C4E 675C 395C 22AA E3CE 2C5C 2D8A \&lNg\9\"...,\-.
[libp7 info]  FA29 A875 5C24 BBDA 3759 AA8A 2729 74B7 .).u\$..7Y..')t.
[libp7 info]  5E6C 5C36 A0F5 265C 3AE6 5C32 3CF5 71CF ^l\6..&\:.\2<.q.
[libp7 info]  77B8 E8FD 89F2 E6A6 5C21 5C3D 6D81 9F5C w.......\!\=m..\
[libp7 info]  2493 5EE2 5C24 CB5C 3479 5C3B 5C28 5F69 $.^.\$.\4y\;\(_i
[libp7 info]  2771 F79D F28F 915C 3580 508B 7E76 7522 'q.....\5.P.~vu"
[libp7 info]  89C1 84BA 5C38 B895 2054 775C 3146 31   ....\8.. Tw\1F1
[libp7 info]  p7_send_ext: packet sent, sending took 1367µs
[libp7 info]  p7_recv_main: it took 1541µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 27275µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 8/8 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3231 3030 3038 3030 3038 .451012100080008
[libp7 info]  A2A7 8CF3 A483 34CB A19F 5C23 FD5C 3474 ......4...\#.\4t
[libp7 info]  6969 3CD8 9898 F245 938E C4EA 517B 8342 ii<....E....Q{.B
[libp7 info]  F28C 7FEB A3EC 7EFA 4FA4 58ED 5C20 C554 ......~.O.X.\ .T
[libp7 info]  DCE0 AB83 3D5C 3471 CE8E A7DB 7E82 20CF ....=\4q....~. .
[libp7 info]  AD5C 285C 2635 A7D9 D326 7547 3D38 5BA3 .\(\&5...&uG=8[.
[libp7 info]  5DCB C65C 39F6 AF74 CEC0 2595 E03E 4A95 ]..\9..t..%..>J.
[libp7 info]  C3B6 5C2B AD3C 615E 78E2 EA4A 8FB0 F5FF ..\+.<a^x..J....
[libp7 info]  D23E 54FD 6E2E CEA3 3A5C 3EAC 5532 CF4C .>T.n...:\>.U2.L
[libp7 info]  C485 3D60 45C6 5C27 6149 2D33 3CC2 3790 ..=`E.\'aI-3<.7.
[libp7 info]  9085 AE80 DE5C 3CE8 497B 62C3 54CC 865C .....\<.I{b.T..\
[libp7 info]  3AC2 DB5C 33F5 A45C 5C74 82D1 B044 3A77 :..\3..\\t...D:w
[libp7 info]  DE24 CD5C 39A7 DC7E F83D EDDC AEA1 5C39 .$.\9..~.=....\9
[libp7 info]  BF46 E8B9 CF56 5C2F 5997 CD8A C9BB 6B64 .F...V\/Y.....kd
[libp7 info]  83BA 52E2 575C 2A20 E6FB FD9C 58DB 3866 ..R.W\* ....X.8f
[libp7 info]  C294 BBDE 4D4C 5C25 E958 88A3 25B6 8034 ....ML\%.X..%..4
[libp7 info]  4F86 ACAD B340 A879 EACC F4B5 B742 F2DF O....@.y.....B..
[libp7 info]  68DA BBE9 E7B8 5C2B 5C27 3C5C 245C 2682 h.....\+\'<\$\&.
[libp7 info]  68B4 5B8C 445C 345C 3B38 45             h.[.D\4\;8E
[libp7 info]  p7_send_ext: packet sent, sending took 1155µs
[libp7 info]  p7_recv_main: it took 1457µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 28430µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: Sending completed in 253654µs
[libp7 info]  p7_term: sending terminate
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  1830 3030 3730                          .00070
[libp7 info]  p7_send_basic: packet sent, sending took 334µs
[libp7 info]  p7_recv_main: it took 525µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 25214µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
Part of the Planète Casio community (FR) - main author of Cahute

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Protocol 7.00 - Slowness and solutions

Postby SimonLothar » Fri Sep 02, 2016 7:03 pm

cakeisalie5 wrote:I'll take the simple file sending example (the file request is more tricky). For a normal packet flow (check[ini], ack, command, ack, {data, ack}, term, ack), the calculator takes ~30ms to answer each data packet. I have found out on the older transfer software (called "UsbConnector" and made by Nessotrin, part of the Planète Casio community) that he uses a special technique to make file sending quicker : he sends two initial check packets and only answers one. I have spontaneously called this technique "packet shifting" and it looks pretty dangerous (he always sends an overwrite, so he doesn't care, but as I use the protocol part about overwrite confirmation to interactively ask to the user if he wants to overwrite...), and my (few) tests didn't succeed in shifting packets other than initial check packets (which means I cannot disable it for interactive parts of the protocol then enable it for data transfer). And I haven't yet thought about how packet shifting could apply for file requesting (roleswap makes it tricky)... but results are here : the calculator takes ~3ms to answer, 10 times less.
This staggered processing seems to work indeed.

I had to apply only minor adjustments to my transfer program.
After sending the first data packet, the program omits the wait-loop for the first ack-packet. Instead it sends the second data-packet immediately.
While the external program sends the second data packet, the calculator simultaneously processes the first data-packet and sends the ack-packet subsequently.
After sending the second data packet, the program has to wait for the ack-packet of the first data packet a. s. o..
After the last data packet has been send, two ack-packets are to expect.

This doubles the file transfer speed on my system!
Smart idea. Well done. THX.
I'll be back!

Senior Member
User avatar
Posts: 101
Joined: Sun Mar 27, 2016 10:24 am
Location: France
Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50

Re: Protocol 7.00 - Slowness and solutions

Postby cakeisalie5 » Fri Sep 02, 2016 7:54 pm

Have you found workarounds for interactive parts of the packet flow (overwrite confirmation) and the passive packet flows (file requests) ? Oo
Part of the Planète Casio community (FR) - main author of Cahute

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Protocol 7.00 - Slowness and solutions

Postby SimonLothar » Fri Sep 02, 2016 9:47 pm

cakeisalie5 wrote:Have you found workarounds for interactive parts of the packet flow (overwrite confirmation) and the passive packet flows (file requests) ? Oo
I use OW=02 in the ST=45-command packet (as you did in your samples). There is no interactive part involved. What workarounds do you refer to?
I'll be back!

Senior Member
User avatar
Posts: 101
Joined: Sun Mar 27, 2016 10:24 am
Location: France
Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50

Re: Protocol 7.00 - Slowness and solutions

Postby cakeisalie5 » Sat Sep 03, 2016 11:37 pm

Well, I would like to have this speed using this technique, to shift packets whenever I want. But I finally managed to get in touch with Nessotrin (the author of the software I took that idea off), and he answered me this (clumsy translation, I should really work on improving my english some time) :

"Well, for the duplicate packet, according to fxReverse, the start of the communication must be followed with a command giving plenty of info about the machine, I skipped it and saw the first packet always resulted in a timeout, so I've put a useless packet so it gets lost without making the program wait"

So it gave me an idea : command packet 0x01 should make packet shifting in a packet flow possible. The idea is the following : we do the interactive part (send request, omg it exists, but yes I want to overwrite, and calculator accepts), then we send the 0x01 command packet two times (shifting), send data (resend errors will surely be tricky but I should manage this using two sending buffers, alternating between them) and unshift (receive without prior sending, managing the unprobable error that could happen at this point). If I remember well, I think I tried this with a non-initial check packet, but calculator reacted in a weird way. I'll try this as soon as possible, and put the results here :)

EDIT: while I'm at it, here's the log with a 'meanwhile' check packet shifting (and its weird bug) :
log: Show
Code: Select all
[libp7 info]  p7_init: creating libusb context
[libp7 info]  p7_init: checking for the calculator
[libp7 info]  p7_init: getting the device handler
[libp7 info]  p7_start: sending initial check
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  0530 3030 3730                          .00070
[libp7 info]  p7_send_basic: packet sent, sending took 384µs
[libp7 info]  p7_recv_main: it took 0µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 25740µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_start: checking check answer
[libp7 info]  p7_sendfile: calculating given file size
[libp7 info]  p7_sendfile: filesize is 17941o
[libp7 info]  p7_sendstream: sending file transfer command
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0134 3531 3030 3236 3032 3030 3030 3030 .451002602000000
[libp7 info]  3436 3135 3030 3041 3030 3030 3034 3030 4615000A00000400
[libp7 info]  4C49 4345 4E53 452E 6D64 666C 7330 3830 LICENSE.mdfls080
[libp7 info]  p7_send_ext: packet sent, sending took 211µs
[libp7 info]  p7_recv_main: it took 379µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 54479µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: checking file transfer answer
[libp7 info]  p7_sendstream: about to send 71 packets
[libp7 info]  p7_sendstream: last one is irregular and contains 21o
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  0530 3130 3646                          .0106F
[libp7 info]  p7_send_basic: packet sent, sending took 320µs
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  0530 3130 3646                          .0106F
[libp7 info]  p7_send_basic: packet sent, sending took 339µs
[libp7 info]  p7_recv_main: it took 794µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 6024µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  1530 3430 3643                          .0406C
[libp7 info]  p7_recv_main: packet was interpreted as an error one
[libp7 info]  p7_recv_main: error is 'overwrite impossible' (0x4)
[libp7 info]  p7_sendstream: sending packet 1/71 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3046 3030 3437 3030 3031 .451010F00470001
[libp7 info]  474E 5520 4765 6E65 7261 6C20 5075 626C GNU General Publ
[libp7 info]  6963 204C 6963 656E 7365 5C2A 3D3D 3D3D ic License\*====
[libp7 info]  3D3D 3D3D 3D3D 3D3D 3D3D 3D3D 3D3D 3D3D ================
[libp7 info]  3D3D 3D3D 3D3D 5C2A 5C2A 5F56 6572 7369 ======\*\*_Versi
[libp7 info]  6F6E 2032 2C20 4A75 6E65 2031 3939 315F on 2, June 1991_
[libp7 info]  2020 5C2A 5F43 6F70 7972 6967 6874 20C2   \*_Copyright .
[libp7 info]  A920 3139 3839 2C20 3139 3931 2046 7265 . 1989, 1991 Fre
[libp7 info]  6520 536F 6674 7761 7265 2046 6F75 6E64 e Software Found
[libp7 info]  6174 696F 6E2C 2049 6E63 2E2C 5F20 205C ation, Inc.,_  \
[libp7 info]  2A5F 3531 2046 7261 6E6B 6C69 6E20 5374 *_51 Franklin St
[libp7 info]  7265 6574 2C20 4669 6674 6820 466C 6F6F reet, Fifth Floo
[libp7 info]  722C 2042 6F73 746F 6E2C 204D 4120 3032 r, Boston, MA 02
[libp7 info]  3131 302D 3133 3031 2055 5341 5F5C 2A5C 110-1301 USA_\*\
[libp7 info]  2A45 7665 7279 6F6E 6520 6973 2070 6572 *Everyone is per
[libp7 info]  6D69 7474 6564 2074 6F20 636F 7079 2061 mitted to copy a
[libp7 info]  6E64 2064 6973 7472 6962 7574 6520 7665 nd distribute ve
[libp7 info]  7262 6174 696D 2031 41                  rbatim 1A
[libp7 info]  p7_send_ext: packet sent, sending took 1122µs
[libp7 info]  p7_recv_main: it took 1367µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 163µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  0630 3030 3730                          .00070
[libp7 info]  p7_recv_main: packet was interpreted as an ack one
[libp7 info]  p7_sendstream: sending packet 2/71 (256o)
[libp7 info]  p7_send_ext: sending the following extended packet :
[libp7 info]  0234 3531 3031 3046 3030 3437 3030 3032 .451010F00470002
[libp7 info]  636F 7069 6573 5C2A 6F66 2074 6869 7320 copies\*of this
[libp7 info]  6C69 6365 6E73 6520 646F 6375 6D65 6E74 license document
[libp7 info]  2C20 6275 7420 6368 616E 6769 6E67 2069 , but changing i
[libp7 info]  7420 6973 206E 6F74 2061 6C6C 6F77 6564 t is not allowed
[libp7 info]  2E5C 2A5C 2A23 2323 2050 7265 616D 626C .\*\*### Preambl
[libp7 info]  655C 2A5C 2A54 6865 206C 6963 656E 7365 e\*\*The license
[libp7 info]  7320 666F 7220 6D6F 7374 2073 6F66 7477 s for most softw
[libp7 info]  6172 6520 6172 6520 6465 7369 676E 6564 are are designed
[libp7 info]  2074 6F20 7461 6B65 2061 7761 7920 796F  to take away yo
[libp7 info]  7572 5C2A 6672 6565 646F 6D20 746F 2073 ur\*freedom to s
[libp7 info]  6861 7265 2061 6E64 2063 6861 6E67 6520 hare and change
[libp7 info]  6974 2E20 2042 7920 636F 6E74 7261 7374 it.  By contrast
[libp7 info]  2C20 7468 6520 474E 5520 4765 6E65 7261 , the GNU Genera
[libp7 info]  6C20 5075 626C 6963 5C2A 4C69 6365 6E73 l Public\*Licens
[libp7 info]  6520 6973 2069 6E74 656E 6465 6420 746F e is intended to
[libp7 info]  2067 7561 7261 6E74 6565 2079 6F75 7220  guarantee your
[libp7 info]  6672 6565 646F 6D31 43                  freedom1C
[libp7 info]  p7_send_ext: packet sent, sending took 1258µs
[libp7 info]  p7_recv_main: it took 1478µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 220µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  1530 3430 3643                          .0406C
[libp7 info]  p7_recv_main: packet was interpreted as an error one
[libp7 info]  p7_recv_main: error is 'overwrite impossible' (0x4)
[libp7 error] p7_sendstream: calculator didn't send ack, weird
The calculator didn't act as planned.
Stop receive mode on calculator and start it again before re-running p7.
[libp7 info]  p7_term: sending terminate
[libp7 info]  p7_send_basic: sending the following basic packet :
[libp7 info]  1830 3030 3730                          .00070
[libp7 info]  p7_send_basic: packet sent, sending took 282µs
[libp7 info]  p7_recv_main: it took 400µs to come back here
[libp7 info]  p7_recv_main: receiving the packet...
[libp7 info]  p7_recv_main: packet received, sending took 23856µs
[libp7 info]  p7_recv_main: received the following packet :
[libp7 info]  1530 3430 3643                          .0406C
[libp7 info]  p7_recv_main: packet was interpreted as an error one
[libp7 info]  p7_recv_main: error is 'overwrite impossible' (0x4)
Part of the Planète Casio community (FR) - main author of Cahute

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Protocol 7.00 - Slowness and solutions

Postby SimonLothar » Sun Sep 04, 2016 3:51 pm

1530 3430 3643 .0406C

The error packet 04 is not necessarily caused by an overwrite problem as designated in fxReverse.
Mannuel Naranjo and Andreas Bertheussen did their research in very early days. Possibly with fx9860 OS 1.02.
The error packet 04 is used as well, if the last sent command has been invalid.

Try the following:
Do not send any check packets between command-45-packet and the first data-45-packet.
Send the first data-45-packet immediately after the command-45-packet.
Do not wait for the ack-packet after having sent the command-45-packet.
Wait for an ack-packet after every data-45-packet.
Thus - while the calculator is processing the previous packet - you send the next packet simultaneously instead of idle waiting. That is the advantage.
After having sent the last data-45-packet wait for two ack-packets.
I'll be back!

Senior Member
User avatar
Posts: 101
Joined: Sun Mar 27, 2016 10:24 am
Location: France
Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50

Re: Protocol 7.00 - Slowness and solutions

Postby cakeisalie5 » Sun Sep 04, 2016 7:55 pm

Okay, so I took your idea of using command and first data packet to shift, but in order to accept interactive parts (that comes between command and first data packet), I used first two data packets (or only data packet and what comes right after). It works like a charm. Thanks for the idea, it was brilliant !

I'll see if I can find something similar with packet flows including roleswapping (like file requesting).
Part of the Planète Casio community (FR) - main author of Cahute

Return to Calculator Hacking/Modding Discussions

Who is online

Users browsing this forum: No registered users and 33 guests