Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2014-12-13 18:09:50

iceman
Administrator
Registered: 2013-04-25
Posts: 9,507
Website

Codestyle: Prefered way of waiting for GetFromBigBuf?

which is the pefered way of waiting for the GetFromBigBuf?  Is it with timeout or not?


  GetFromBigBuf(data,BUFF_SIZE,3560);  //3560 -- should be offset..
  WaitForResponseTimeout(CMD_ACK,NULL, 1500);

VS

  GetFromBigBuf(data,BUFF_SIZE,3560);  //3560 -- should be offset..
  WaitForResponse(CMD_ACK,NULL);

Offline

#2 2014-12-14 09:33:31

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Re: Codestyle: Prefered way of waiting for GetFromBigBuf?

Depends on what you want... Both can be aborted with user-click. If you specify no timeout or greater than a certain value (perhaps 3s), it will say "press button to abort". If the operation is "sim", you want to basically keep doing it indefinitely (no timeout, or exteranlly loop around a small timeout-value). If the operation is just to do something which is supposed to be quick, you can use a couple of seconds timeout. Look inside to see how it works.

Offline

#3 2014-12-14 10:50:37

iceman
Administrator
Registered: 2013-04-25
Posts: 9,507
Website

Re: Codestyle: Prefered way of waiting for GetFromBigBuf?

but if you do a sim, you don't want to wait for an response at all.  Fire and forget.  Just press button when done.

it's like a poor man version of errorchecking,  did it react within 1500millisec? nop,  well, then something went wrong.  smile

Offline

#4 2014-12-14 13:27:49

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Re: Codestyle: Prefered way of waiting for GetFromBigBuf?

The thing is, it's not a question of codestyle. It's just how you want to use it.
The comms are asynchronous. If you have an 'return immediately'-command, like 'data samples 2000', you expect the device to return the data 'immediately'. On the client side, it's still asynchronous - you need to specify how long you want to wait.

In my scripts, I usually loop around a smaller value, to surpress the "Press button to abort" - message. Because I print that info from the script itself. In a sim, you *may* want to handle the return value, as opposed to return to console. In my scripts, I maybe want to do a sim, then wait for the return value. So there are different aspects to think about. tldr; not a question of codestyle.

But more specifically, if you're getting from bigbuf, use 1500 instead. If it hasn't returned by then, something is wrong. No use in waiting indefinitely.

Offline

Board footer

Powered by FluxBB