Lego Mindstorm:连接到 Lego Brick 对象后无法观察操作
Lego Mindstorm: Unable to observe operations after connecting to Lego Brick object
成功连接乐高积木后无法观察到任何操作
此代码有效:
let brick = Brick(BluetoothCommunication "COM3")
let result = brick.ConnectAsync().RunSynchronously
但是,我无法观察到连续命令(即声音和电机)的任何确认。
客户代码:
open MyLego.Core
[<EntryPoint>]
let main argv =
let example = LegoExample()
0 // return an integer exit code
域逻辑
namespace MyLego.Core
open Lego.Ev3.Core
open Lego.Ev3.Desktop
type LegoExample() =
let volume = 100
let frequency = 1000
let duration = 300
let power = 50
let breakSetting = false
let brick = Brick(BluetoothCommunication "COM3")
do brick.BrickChanged.Add(fun e -> printfn "Brick changed")
let result = brick.ConnectAsync().RunSynchronously
let move = brick.DirectCommand.TurnMotorAtPowerForTimeAsync(
OutputPort.B ||| OutputPort.C, power, uint32 duration, breakSetting).RunSynchronously
let playTone = brick.DirectCommand.PlayToneAsync(
volume, uint16 frequency, uint16 duration).RunSynchronously
请注意,我正在构造函数中执行所有这些操作。可以吗?
我参考了以下文档:
原来是蓝牙连接问题
当我使用 USB 时,我观察到了预期的行为。
显然以下异常被吞没了:
"there is no user session key for the specified logon session"
但是,此异常仅在 C# 实现中出现。
成功连接乐高积木后无法观察到任何操作
此代码有效:
let brick = Brick(BluetoothCommunication "COM3")
let result = brick.ConnectAsync().RunSynchronously
但是,我无法观察到连续命令(即声音和电机)的任何确认。
客户代码:
open MyLego.Core
[<EntryPoint>]
let main argv =
let example = LegoExample()
0 // return an integer exit code
域逻辑
namespace MyLego.Core
open Lego.Ev3.Core
open Lego.Ev3.Desktop
type LegoExample() =
let volume = 100
let frequency = 1000
let duration = 300
let power = 50
let breakSetting = false
let brick = Brick(BluetoothCommunication "COM3")
do brick.BrickChanged.Add(fun e -> printfn "Brick changed")
let result = brick.ConnectAsync().RunSynchronously
let move = brick.DirectCommand.TurnMotorAtPowerForTimeAsync(
OutputPort.B ||| OutputPort.C, power, uint32 duration, breakSetting).RunSynchronously
let playTone = brick.DirectCommand.PlayToneAsync(
volume, uint16 frequency, uint16 duration).RunSynchronously
请注意,我正在构造函数中执行所有这些操作。可以吗?
我参考了以下文档:
原来是蓝牙连接问题
当我使用 USB 时,我观察到了预期的行为。
显然以下异常被吞没了:
"there is no user session key for the specified logon session"
但是,此异常仅在 C# 实现中出现。