OLD | NEW |
(Empty) | |
| 1 --- |
| 2 title: Fletch tool details |
| 3 layout: page |
| 4 --- |
| 5 |
| 6 # Fletch tool details |
| 7 |
| 8 ## Running code locally and remotely |
| 9 |
| 10 In the [getting started instructions](index.html) we tried running programs both |
| 11 on the local PC, and on a remote Raspberry Pi. Are you curious how that works in |
| 12 details? |
| 13 |
| 14 When you run a program with ```fletch run``` it always runs in a 'session'. You |
| 15 can specify the name of the session with an additional argument after run: |
| 16 ```fletch run in session <session name>```. If you omit the session part, then |
| 17 the tool default to a session called ```local```. |
| 18 |
| 19 The settings for these sessions are defined in configuration files located in |
| 20 the path ```<user home directory>/<session name>.fletch-settings```. If you take |
| 21 a look at the remote settings file, you will see this content (exact path and |
| 22 IP will differ on your PC): |
| 23 |
| 24 ~~~ |
| 25 { |
| 26 "packages": "file:///Users/mit/fletch-sdk/internal/fletch-sdk.packages", |
| 27 "options": [], |
| 28 "constants": {}, |
| 29 "device_address": "192.168.2.2:12121" |
| 30 } |
| 31 ~~~ |
| 32 |
| 33 The ```device_address``` tag tells fletch where to locate the VM Agent on your |
| 34 attached device. If the IP of that device changes, then you need to update this |
| 35 tag. |
| 36 |
| 37 ## Debugging |
| 38 |
| 39 Fletch also supports debugging. Let's try to debug the Knight Rider sample. |
| 40 Start by running the following command in your terminal: |
| 41 |
| 42 ~~~ |
| 43 debug $HOME/fletch-sdk/samples/raspberry_pi/basic/knight-rider.dart in session r
emote |
| 44 ~~~ |
| 45 |
| 46 You should see the terminal change to: |
| 47 |
| 48 ~~~ |
| 49 Starting session. Type 'help' for a list of commands. |
| 50 |
| 51 > |
| 52 ~~~ |
| 53 |
| 54 Let's set a breakpoint in the _setLeds method, and start the execution of the |
| 55 program: |
| 56 |
| 57 ~~~ |
| 58 b _setLeds |
| 59 r |
| 60 ~~~ |
| 61 |
| 62 We are now inside the _setLeds method. Let's see what the initial state is: Type
```p```. You should see this output |
| 63 |
| 64 ~~~ |
| 65 ledToEnable: 0 |
| 66 this: Instance of 'Lights' |
| 67 > |
| 68 ~~~ |
| 69 |
| 70 Try to step a few more times (with the ```s``` command), and then print out the |
| 71 local variable again (with the ```p``` command). You should see ledToEnable |
| 72 increment up to the numner of LEDs you have, and then you should see it start |
| 73 decrementing. Pretty neat right!? |
OLD | NEW |