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 argument, |
| 17 then the tool defaults to the ```local``` session where the program is run on |
| 18 the local PC. |
| 19 |
| 20 The settings for these sessions are defined in configuration files located in |
| 21 the path ```<user home directory>/<session name>.fletch-settings```. If you take |
| 22 a look at the remote settings file, you will see this content (exact path and |
| 23 IP will differ on your PC): |
| 24 |
| 25 ~~~ |
| 26 { |
| 27 "packages": "file:///Users/mit/fletch-sdk/internal/fletch-sdk.packages", |
| 28 "options": [], |
| 29 "constants": {}, |
| 30 "device_address": "192.168.2.2:12121" |
| 31 } |
| 32 ~~~ |
| 33 |
| 34 The ```device_address``` tag tells fletch where to locate the VM Agent on your |
| 35 attached device. If the IP of that device changes, then you need to update this |
| 36 tag. If the value is omitted or set to null, Fletch will run locally. |
| 37 |
| 38 ## Debugging |
| 39 |
| 40 Fletch also supports debugging. Let's try to debug the Knight Rider sample. |
| 41 Start by running the following command in your terminal: |
| 42 |
| 43 ~~~ |
| 44 debug $HOME/fletch-sdk/samples/raspberry_pi/basic/knight-rider.dart in session r
emote |
| 45 ~~~ |
| 46 |
| 47 You should see the terminal change to: |
| 48 |
| 49 ~~~ |
| 50 Starting session. Type 'help' for a list of commands. |
| 51 |
| 52 > |
| 53 ~~~ |
| 54 |
| 55 Let's set a breakpoint in the _setLeds method, and start the execution of the |
| 56 program: |
| 57 |
| 58 ~~~ |
| 59 b _setLeds |
| 60 r |
| 61 ~~~ |
| 62 |
| 63 We are now inside the _setLeds method. Let's see what the initial state is: Type
```p```. You should see this output |
| 64 |
| 65 ~~~ |
| 66 ledToEnable: 0 |
| 67 this: Instance of 'Lights' |
| 68 > |
| 69 ~~~ |
| 70 |
| 71 Try to step a few more times (with the ```s``` command), and then print out the |
| 72 local variable again (with the ```p``` command). You should see ledToEnable |
| 73 increment up to the numner of LEDs you have, and then you should see it start |
| 74 decrementing. Pretty neat right!? |
OLD | NEW |