Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.

Commit 0733364

Browse files
committed
Version 0.5.0-dev.1.1
Cherry-pick 435ddbc to dev Cherry-pick e483c95 to dev Cherry-pick ae63c06 to dev Cherry-pick 3695591 to dev Cherry-pick 2004f8c to dev
2 parents 384dee1 + 1c7d03b commit 0733364

File tree

19 files changed

+312
-106
lines changed

19 files changed

+312
-106
lines changed

lib/dartino_embedded.platform

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ core: core/embedded_core.dart
2424

2525
math: ../third_party/dart/sdk/lib/math/math.dart
2626
typed_data: ../third_party/dart/sdk/lib/typed_data/typed_data.dart
27-
developer: ../third_party/dart/sdk/lib/developer/developer.dart
2827
collection: ../third_party/dart/sdk/lib/collection/collection.dart
2928

3029
_internal: ../third_party/dart/sdk/lib/internal/internal.dart

lib/dartino_mobile.platform

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ async: ../third_party/dart/sdk/lib/async/async.dart
2323
collection: ../third_party/dart/sdk/lib/collection/collection.dart
2424
convert: ../third_party/dart/sdk/lib/convert/convert.dart
2525
core: ../third_party/dart/sdk/lib/core/core.dart
26-
developer: ../third_party/dart/sdk/lib/developer/developer.dart
2726
math: ../third_party/dart/sdk/lib/math/math.dart
2827
typed_data: ../third_party/dart/sdk/lib/typed_data/typed_data.dart
2928

pkg/dartino/lib/_embedder.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ embedded_libs:
1414
'dart:dartino._ffi': '../../../internal/dartino_lib/ffi/ffi_private.dart'
1515
'dart:dartino.os': '../../../lib/os/os.dart'
1616
'dart:dartino.service': '../../../lib/service/service.dart'
17-
'dart:developer': '../../../third_party/dart/sdk/lib/developer/developer.dart'
1817
'dart:math': '../../../third_party/dart/sdk/lib/math/math.dart'
1918
'dart:typed_data': '../../../third_party/dart/sdk/lib/typed_data/typed_data.dart'

pkg/dartino_compiler/lib/src/verbs/debug_verb.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Future<int> serveDebuggerTask(
159159
SessionState state,
160160
Uri script,
161161
Uri base,
162-
{Uri snapshotLocation}) {
162+
{Uri snapshotLocation}) async {
163163
DartinoVmContext vmContext = state.vmContext;
164164
if (vmContext == null) {
165165
throwInternalError("Not connected to a dartino vm.");
@@ -169,11 +169,13 @@ Future<int> serveDebuggerTask(
169169
throwFatalError(DiagnosticKind.compileBeforeRun);
170170
}
171171

172+
int result = await new DebugServer()
173+
.serveSingleShot(state, snapshotLocation: snapshotLocation);
174+
172175
// Make sure current state's vmContext is not reused if invoked again.
173176
state.vmContext = null;
174177

175-
return new DebugServer()
176-
.serveSingleShot(state, snapshotLocation: snapshotLocation);
178+
return result;
177179
}
178180

179181
Future<int> interactiveDebuggerTask(

pkg/dartino_compiler/lib/src/worker/developer.dart

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,21 @@ Future<int> analyze(
261261
Uri base) async {
262262
Directory dartSdkDir = await locateDartSdkDirectory();
263263
String analyzerPath = join(dartSdkDir.path, 'bin', 'dartanalyzer');
264+
Uri pkgsUri = state.settings.packages;
265+
266+
// If running within the repo, then use a different packages file
267+
String relPath = 'pkg/dartino_compiler/lib/dartino_compiler.dart';
268+
if (await new File.fromUri(pkgsUri.resolve(relPath)).exists()) {
269+
pkgsUri = pkgsUri.resolve('pkg/dartino-sdk.packages');
270+
if (!await new File.fromUri(pkgsUri).exists()) {
271+
throwInternalError("Failed to find dartino-sdk.packages file");
272+
}
273+
}
264274

265275
List<String> arguments = <String>[];
266276
arguments.add('--strong');
267277
arguments.add('--packages');
268-
arguments.add(new File.fromUri(state.settings.packages).path);
278+
arguments.add(new File.fromUri(pkgsUri).path);
269279
arguments.add(new File.fromUri(fileUri).path);
270280

271281
state.log('Analyze: $analyzerPath ${arguments.join(' ')}');
@@ -1377,24 +1387,21 @@ Future<Device> readDevice(String deviceId) async {
13771387
return parseDevice(jsonLikeData, uri, libraryDirectoryUri);
13781388
} else {
13791389
throw uri;
1380-
return null;
13811390
}
13821391
}
13831392

13841393
Future<Directory> locateDartSdkDirectory() async {
13851394
// In the SDK, the dart-sdk directory is in the internal directory.
1386-
Directory dartSdkDirectory =
1387-
new Directory.fromUri(executable.resolve(
1388-
'../internal/dart-sdk'));
1389-
if (!await dartSdkDirectory.exists()) {
1390-
// When running in a Git checkout...
1391-
dartSdkDirectory =
1392-
new Directory.fromUri(executable.resolve(
1393-
'dartino-sdk/internal/dart-sdk'));
1394-
assert(await dartSdkDirectory.exists());
1395-
}
1396-
1397-
return dartSdkDirectory;
1395+
Uri dartSdkUri = executable.resolve('../internal/dart-sdk');
1396+
Directory dartSdkDir = new Directory.fromUri(dartSdkUri);
1397+
if (await dartSdkDir.exists()) return dartSdkDir;
1398+
1399+
// In a Git checkout, the the dart-sdk directory is in third_party
1400+
String os = Platform.isMacOS ? 'mac' : Platform.operatingSystem;
1401+
dartSdkUri = executable.resolve('../../third_party/dart-sdk/$os/dart-sdk');
1402+
dartSdkDir = new Directory.fromUri(dartSdkUri);
1403+
assert(await dartSdkDir.exists());
1404+
return dartSdkDir;
13981405
}
13991406

14001407
// Creates a c-file containing the options options in an array.

pkg/gpio/lib/gpio.dart

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,55 @@
44

55
/// GPIO support providing access to controlling GPIO pins.
66
///
7-
/// Currently this has only been tested with a Raspberry Pi 2 and the
8-
/// STM32F746G-Discovery board.
7+
/// Currently this has been tested with the STM32F746G Discovery and
8+
/// STM32411RE Nucleo boards and on a Raspberry Pi 2.
99
///
10-
/// Access types
11-
/// ------------
12-
/// There are two ways of accessing the GPIO pins: direct access or
13-
/// access through a Sysfs driver.
10+
/// Usage on STM32F746G Discovery board
11+
/// -----------------------------------
12+
/// ```dart
13+
/// import 'dart:dartino';
14+
///
15+
/// import 'package:gpio/gpio.dart';
16+
/// import 'package:stm32/stm32f746g_disco.dart';
17+
///
18+
/// main() {
19+
/// // Initialize STM32F746G Discovery board and configure the pin.
20+
/// STM32F746GDiscovery board = new STM32F746GDiscovery();
21+
/// GpioOutputPin pin = board.gpio.initOutput(STM32F746GDiscovery.LED1);
22+
///
23+
/// // Toggle the pin every half second.
24+
/// while (true) {
25+
/// pin.toggle();
26+
/// sleep(500);
27+
/// }
28+
/// }
29+
/// ```
30+
///
31+
/// Usage on STM32411RE Nucleo board
32+
/// --------------------------------
33+
/// ```dart
34+
/// import 'dart:dartino';
35+
///
36+
/// import 'package:gpio/gpio.dart';
37+
/// import 'package:stm32/stm32f411re_nucleo.dart';
38+
///
39+
/// main() {
40+
/// // Initialize STM32411RE Nucleo board and configure the pin.
41+
/// STM32F411RENucleo board = new STM32F411RENucleo();
42+
/// GpioOutputPin pin = board.gpio.initOutput(STM32F411RENucleo.LED2);
43+
///
44+
/// // Toggle the pin every half second.
45+
/// while (true) {
46+
/// pin.toggle();
47+
/// sleep(500);
48+
/// }
49+
/// }
50+
/// ```
51+
///
52+
/// Usage on Raspberry Pi 2
53+
/// -----------------------
54+
/// On the Raspberry Pi 2 there are two ways of accessing the GPIO
55+
/// pins: direct access or access through a Sysfs driver.
1456
///
1557
/// When direct access is used, the physical memory addresses, where the
1658
/// SoC registers for the GPIO pins are mapped, are accessed directly. If this
@@ -21,39 +63,27 @@
2163
/// by default. However this can be changed through udev rules, e.g. by
2264
/// adding a file to ` /etc/udev/rules.d`. In addition the Sysfs driver
2365
/// supports state change notifications.
24-
///
25-
/// Usage on Raspberry Pi 2
26-
/// -----------------------
2766
/// ```dart
67+
/// import 'dart:dartino';
68+
///
2869
/// import 'package:gpio/gpio.dart';
2970
/// import 'package:raspberry_pi/raspberry_pi.dart';
3071
///
3172
/// main() {
32-
/// // Initialize Raspberry Pi and configure the pins.
73+
/// // Initialize Raspberry Pi and configure the pin.
3374
/// RaspberryPi pi = new RaspberryPi();
3475
/// Gpio gpio = pi.memoryMappedGPIO;
3576
/// GpioOutputPin pin = gpio.initOutput(RaspberryPiPin.GPIO6);
3677
///
37-
/// // Access pin.
38-
/// pin.state = true;
39-
/// ```
40-
///
41-
/// Usage on STM32F746G Discovery board
42-
/// -----------------------------------
43-
/// ```dart
44-
/// import 'package:gpio/gpio.dart';
45-
/// import 'package:stm32/stm32f746g_disco.dart';
46-
///
47-
/// main() {
48-
/// // Initialize STM32F746G Discovery board and configure the pins.
49-
/// STM32F746GDiscovery board = new STM32F746GDiscovery();
50-
/// GpioOutputPin pin = board.gpio.initOutput(STM32F746GDiscovery.LED1);
51-
///
52-
/// // Access pin.
53-
/// pin.state = true;
78+
/// // Toggle the pin every half second.
79+
/// while (true) {
80+
/// pin.toggle();
81+
/// sleep(500);
82+
/// }
83+
/// }
5484
/// ```
5585
///
56-
/// See `samples/raspberry_pi/` and `samples/stm32f746g-discovery` for
86+
/// See `samples/raspberry_pi/` and `samples/stm32f746g-discovery` and `samples/stm32f746g-discovery` for
5787
/// additional details.
5888
///
5989
/// Reporting issues

pkg/nucleo_iks01a1/lib/nucleo_iks01a1.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
/// following example uses a STM32F764G Discovery board where the I2C
1010
/// bus on Arduino connector is I2C bus `1`, available as `i2c1`.
1111
///
12+
/// Usage with STM32F746G Discovery board
13+
/// -------------------------------------
14+
/// ```dart
1215
/// import 'package:stm32/stm32f746g_disco.dart';
1316
/// import 'package:nucleo_iks01a1/nucleo_iks01a1.dart';
1417
///
@@ -21,6 +24,7 @@
2124
/// hts221.powerOn();
2225
/// print('Temperature: ${hts221.readTemperature()}');
2326
/// }
27+
/// ```
2428
///
2529
/// The library also contains the default I2C addresses of the sensors
2630
/// on the expansion board.

pkg/socket/lib/socket.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class Socket extends _SocketBase {
8282
}
8383

8484
Socket._connect(String host, int port) {
85-
8685
var address = sys.lookup(host);
8786
if (address == null) _error("Failed to lookup address '$host'");
8887
_fd = sys.socket(sys.AF_INET, sys.SOCK_STREAM, 0);
@@ -272,7 +271,15 @@ class Datagram {
272271

273272
// TODO(karlklose): support IPv6 datagram sockets.
274273
class DatagramSocket extends _SocketBase {
275-
DatagramSocket.bind(String host, int port) {
274+
factory DatagramSocket.bind(String host, int port) {
275+
if (Foreign.platform == Foreign.FREERTOS) {
276+
return new stm32.DatagramSocket.bind(host, port);
277+
} else {
278+
return new DatagramSocket._bind(host, port);
279+
}
280+
}
281+
282+
DatagramSocket._bind(String host, int port) {
276283
InternetAddress address = sys.lookup(host);
277284
if (address == null) _error("Failed to lookup address '$host'");
278285
_fd = sys.socket(sys.AF_INET, sys.SOCK_DGRAM, 0);

pkg/stm32/lib/ethernet.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
library stm32.ethernet;
66

77
import 'dart:dartino.ffi';
8+
import 'package:os/os.dart' as os show InternetAddress;
89

910
final _initializeNetwork =
1011
ForeignLibrary.main.lookup("InitializeNetworkStack");
@@ -13,20 +14,22 @@ final _getEthernetAdapterStatus =
1314
ForeignLibrary.main.lookup("GetEthernetAdapterStatus");
1415
final _getNetworkAddressConfiguration =
1516
ForeignLibrary.main.lookup("GetNetworkAddressConfiguration");
16-
final _lookupHost = ForeignLibrary.main.lookup("LookupHost");
17+
final _lookupHost = ForeignLibrary.main.lookup("network_lookup_host");
1718
final _networkAddressMayHaveChanged = ForeignLibrary.main.lookup(
1819
"NetworkAddressMayHaveChanged");
1920

2021
Ethernet ethernet = new Ethernet._internal();
2122

2223
// TODO(karlklose): use the one in os.dart?
23-
class InternetAddress {
24+
class InternetAddress implements os.InternetAddress {
2425
final List<int> bytes;
2526

2627
const InternetAddress(this.bytes);
2728

2829
toString() => bytes.join('.');
2930

31+
bool get isIP4 => bytes.length == 4;
32+
3033
static final InternetAddress localhost =
3134
const InternetAddress(const <int>[127, 0, 0, 1]);
3235
}
@@ -170,7 +173,7 @@ class _NetworkInterface implements NetworkInterface {
170173
case ETH_INTERFACE_INDEX:
171174
return (_getEthernetAdapterStatus.icall$0() & BMSR_LS_MASK) != 0;
172175
default:
173-
throw new StateError('illegal adapted index: $index');
176+
throw new StateError('illegal adapter index: $index');
174177
}
175178
}
176179
}

0 commit comments

Comments
 (0)