Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
Correct naming of Motor. .. Sync commands in brick mode.
Fix: Writing to files in PC mode was broken
Clean up and fix examples and testsuite
  • Loading branch information
c0pperdragon committed May 28, 2015
1 parent 47e0e53 commit 71fbe82
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 99 deletions.
4 changes: 3 additions & 1 deletion Documentation/ev3basic_manual.html
Expand Up @@ -420,6 +420,8 @@ <H3 class="property">EV3.BatteryLevel - property</H3>
<P class="propertysummary">The current loading level of the battery (range 0 to 100).</P>
<H3 class="property">EV3.Time - property</H3>
<P class="propertysummary">The time in milliseconds since the program was started.</P>
<H3 class="operation">EV3.QueueNextCommand ()</H3>
<P class="operationsummary">Increase performance when program runs in "PC mode": Do not send next command to the brick immediately, but wait until one more command is issued which will then be sent together with the first one. You can bunch more commands together by using an additional call to QueueNextCommand before any command that should be place into the queue.<BR>In "brick mode", this command has no effect.</P>
<H3 class="operation">EV3.SetLEDColor (color, effect)</H3>
<P class="operationsummary">Set the color of the brick LED light and the effect to use for it.</P>
<H4 class="parameter">color</H4>
Expand Down Expand Up @@ -929,7 +931,7 @@ <H4 class="returns">Returns</H4>
<H2 class="object">Sensor</H2>
<P class="objectsummary">Access sensors that are attached to the brick.<BR>To specify the sensor use the port number which is printed below the socket on the brick (for example 1).<BR>To access sensors of further bricks that are connected via daisy-chaining, use the next higher numbers instead (5 - 8 will access the sensors on the first daisy-chained brick, 9-12 the sensors on the next one and so on).</P>
<H3 class="operation">Sensor.CommunicateI2C (port, address, writebytes, readbytes, writedata)</H3>
<P class="operationsummary">Communicates with devices using the I2C protocol over one of the sensor ports.<BR>This command addresses one device on the I2C-bus and can send and receive multiple bytes. This feature could be used to attach a custom sensor or to communicate with any device that is capable to be connected to the I2C bus as a slave.</P>
<P class="operationsummary">Communicates with devices using the I2C protocol over one of the sensor ports.<BR>This command addresses one device on the I2C-bus and can send and receive multiple bytes. This feature could be used to attach a custom sensor or to communicate with any device that is capable to be connected to the I2C bus as a slave.<BR>Note that this command does not work over daisy-chaining.</P>
<H4 class="parameter">port</H4>
<P class="parametersummary">Number of the sensor port</P>
<H4 class="parameter">address</H4>
Expand Down
6 changes: 3 additions & 3 deletions EV3BasicCompiler/Resources/Motor.txt
Expand Up @@ -148,7 +148,7 @@ nottoobig:
OUTPUT_TIME_POWER layer nos pwr 0 2147483647 0 0
}

subcall MOTOR.STARTSYNCHRONIZED // SFFV MOTORDECODEPORTSDESCRIPTOR
subcall MOTOR.STARTSYNC // SFFV MOTORDECODEPORTSDESCRIPTOR
{
IN_S ports 8
IN_F speed1
Expand Down Expand Up @@ -297,7 +297,7 @@ subcall MOTOR.SCHEDULEPOWER // SFFFFSV MOTORDECODEPORTSDESCRIPTOR
}


subcall MOTOR.SCHEDULESYNCHRONIZED // SFFFSV MOTORDECODEPORTSDESCRIPTOR
subcall MOTOR.SCHEDULESYNC // SFFFSV MOTORDECODEPORTSDESCRIPTOR
{
IN_S ports 8
IN_F speed1
Expand Down Expand Up @@ -419,7 +419,7 @@ inline MOTOR.MOVEPOWER // SFFSV MOTOR.SCHEDULEPOWER MOTORDECODEPORTDESCRIP
motornotbusy:#:
}

inline MOTOR.MOVESYNCHRONIZED // SFFFSV MOTOR.SCHEDULESYNCHRONIZED MOTORDECODEPORTDESCRIPTOR
inline MOTOR.MOVESYNC // SFFFSV MOTOR.SCHEDULESYNCHRONIZED MOTORDECODEPORTDESCRIPTOR
{
CALL MOTOR.SCHEDULESYNCHRONIZED :0 :1 :2 :3 :4

Expand Down
51 changes: 13 additions & 38 deletions EV3BasicInstaller/EV3BasicInstaller.vdproj
Expand Up @@ -46,13 +46,13 @@
"Entry"
{
"MsmKey" = "8:_53D194D021287DC4A1CE4CA14B8AB761"
"OwnerKey" = "8:_DB7CB564A6834BB59654A37073F3E2F6"
"OwnerKey" = "8:_4FD91A8516934B519CEFABDCAB429EEB"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_53D194D021287DC4A1CE4CA14B8AB761"
"OwnerKey" = "8:_4FD91A8516934B519CEFABDCAB429EEB"
"OwnerKey" = "8:_DB7CB564A6834BB59654A37073F3E2F6"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
Expand Down Expand Up @@ -106,49 +106,49 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_DB7CB564A6834BB59654A37073F3E2F6"
"OwnerKey" = "8:_53D194D021287DC4A1CE4CA14B8AB761"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_CBDEC7B60E90E4F596B1D9E3A38786F4"
"OwnerKey" = "8:_F5CDD074D58C3554E666A5E4C4C3A927"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_3FB6F29BDB75B4EA09B1C22FDB977915"
"OwnerKey" = "8:_21B8D95FCB7B43E883F73B9387BB339E"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_4FD91A8516934B519CEFABDCAB429EEB"
"OwnerKey" = "8:_2303BCFBEC09CC552C1787A745096EA5"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_2303BCFBEC09CC552C1787A745096EA5"
"OwnerKey" = "8:_4FD91A8516934B519CEFABDCAB429EEB"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_21B8D95FCB7B43E883F73B9387BB339E"
"OwnerKey" = "8:_3FB6F29BDB75B4EA09B1C22FDB977915"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_F5CDD074D58C3554E666A5E4C4C3A927"
"OwnerKey" = "8:_CBDEC7B60E90E4F596B1D9E3A38786F4"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_53D194D021287DC4A1CE4CA14B8AB761"
"OwnerKey" = "8:_DB7CB564A6834BB59654A37073F3E2F6"
"MsmSig" = "8:_UNDEFINED"
}
}
Expand Down Expand Up @@ -253,11 +253,6 @@
"AssemblyAsmDisplayName" = "8:SmallBasicLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_2303BCFBEC09CC552C1787A745096EA5"
{
"Name" = "8:SmallBasicLibrary.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:SmallBasicLibrary.dll"
"TargetName" = "8:"
Expand All @@ -284,11 +279,6 @@
"AssemblyAsmDisplayName" = "8:EV3BasicCompiler, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_3FB6F29BDB75B4EA09B1C22FDB977915"
{
"Name" = "8:EV3BasicCompiler.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:EV3BasicCompiler.dll"
"TargetName" = "8:"
Expand All @@ -315,11 +305,6 @@
"AssemblyAsmDisplayName" = "8:EV3Communication, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_53D194D021287DC4A1CE4CA14B8AB761"
{
"Name" = "8:EV3Communication.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:EV3Communication.dll"
"TargetName" = "8:"
Expand Down Expand Up @@ -366,11 +351,6 @@
"AssemblyAsmDisplayName" = "8:LMSAssembler, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_CBDEC7B60E90E4F596B1D9E3A38786F4"
{
"Name" = "8:LMSAssembler.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:LMSAssembler.dll"
"TargetName" = "8:"
Expand All @@ -397,11 +377,6 @@
"AssemblyAsmDisplayName" = "8:SmallBasicLibrary, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_F5CDD074D58C3554E666A5E4C4C3A927"
{
"Name" = "8:SmallBasicLibrary.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:SmallBasicLibrary.dll"
"TargetName" = "8:"
Expand Down Expand Up @@ -509,7 +484,7 @@
"Product"
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:EV3Basic 1.1"
"ProductName" = "8:EV3Basic 1.0.1"
"ProductCode" = "8:{3A95553D-B104-4714-B572-87E3D602A499}"
"PackageCode" = "8:{8380E5E5-3A3A-4F93-9934-C2E8B6C9BCAE}"
"UpgradeCode" = "8:{3EAEFA4E-8024-4136-8981-0634E86DC49C}"
Expand All @@ -518,11 +493,11 @@
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.1"
"ProductVersion" = "8:1.0.1"
"Manufacturer" = "8:Reinhard Grafl"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
"Title" = "8:EV3Basic 1.1"
"Title" = "8:EV3Basic 1.0.1"
"Subject" = "8:"
"ARPCONTACT" = "8:Reinhard Grafl"
"Keywords" = "8:"
Expand Down
33 changes: 0 additions & 33 deletions Examples/FastSensor.sb

This file was deleted.

10 changes: 5 additions & 5 deletions Examples/TwoMotorMovement.sb
@@ -1,4 +1,4 @@
Y_PREV = 0 ' memorize position of motor D
Y_PREV = 0 ' memorize position of motor C

For X=1 To 360 ' move steps of single degrees
Y = 50*Math.Sin(X/180*Math.PI) ' calculate Y dependent of X
Expand All @@ -9,11 +9,11 @@ For X=1 To 360 ' move steps of single degrees

Motor.SchedulePower("A",30,0,1,0,"true") ' move A by one degree

If Y_INC>0 Then ' move motor D either forward
Motor.SchedulePower("D",30,0,Y_INC,0,"true")
If Y_INC>0 Then ' move motor C either forward
Motor.SchedulePower("C",30,0,Y_INC,0,"true")
Else ' or backwards
Motor.SchedulePower("D",-30,0,Y_INC,0,"true")
Motor.SchedulePower("C",-30,0,Y_INC,0,"true")
EndIf

Motor.Wait("AD") ' wait until both motors have reached the position
Motor.Wait("AC") ' wait until both motors have reached the position
EndFor
10 changes: 5 additions & 5 deletions SmallBasicEV3Extension/EV3File.cs
Expand Up @@ -33,7 +33,7 @@ namespace SmallBasicEV3Extension
[SmallBasicType]
public static class EV3File
{
static FileHandle[] openFiles = new FileHandle[100];
static FileHandle[] openFiles = new FileHandle[100]; // all file handles in use (0 will not be used at any time)


private static Primitive OpenWriteImpl(Primitive filename, bool append)
Expand All @@ -60,13 +60,13 @@ private static Primitive OpenWriteImpl(Primitive filename, bool append)
c.OP(0xC0); // opFile
c.CONST(append ? 0x00: 0x02); // OPEN_APPEND = 0x00 OPEN_WRITE = 0x02
c.STRING(f);
c.LOCVAR(0); // result: 16-bit handle
c.GLOBVAR(0); // result: 16-bit handle
c.OP(0xC0); // opFile
c.CONST(0x07); // CLOSE = 0x07
c.LOCVAR(0);
c.GLOBVAR(0);

// check if could indeed create/append file on the brick
byte[] reply = EV3RemoteControler.DirectCommand(c, 0, 1);
byte[] reply = EV3RemoteControler.DirectCommand(c, 2, 0);

if (reply==null || reply.Length<2 || (reply[0]==0 && reply[1]==0))
{
Expand Down Expand Up @@ -215,7 +215,7 @@ public static void WriteByte(Primitive handle, Primitive data)
c.LOCVAR(2); // where to take the byte from
c.OP(0xC0); // opFile
c.CONST(0x07); // CLOSE = 0x07
c.GLOBVAR(0);
c.LOCVAR(0);
EV3RemoteControler.DirectCommand(c, 0, 3);
}
}
Expand Down
10 changes: 6 additions & 4 deletions testsuite/ev3features/ConcurrentWaits.sb
Expand Up @@ -7,9 +7,10 @@ Sub t1
While "True"
Sensor.Wait(1) ' wait until ready (must not block other thread)
If (Sensor.ReadPercent(1)>50) Then
Motor.SchedulePowerForTime("A", 50, 0,1000,0, "true")
Motor.StartPower("A", 50)
Program.Delay(1000)
Motor.Stop("A", "true")
EndIf
Motor.Wait("A")

' give visual hint, that this thread is running
x1=Math.Remainder(x1+1,2)
Expand All @@ -28,9 +29,10 @@ Sub t2
While "True"
Sensor.Wait(2) ' wait until ready (must not block other thread)
If (Sensor.ReadPercent(2)>50) Then
Motor.SchedulePowerForTime("B", 50, 0,1000,0, "true")
Motor.StartPower("B", 50)
Program.Delay(1000)
Motor.Stop("B","true")
EndIf
Motor.Wait("B")

' give acoustic hint, that this thread is running
Speaker.Tone(5,440,100)
Expand Down
17 changes: 9 additions & 8 deletions testsuite/ev3features/FileAccess.sb
@@ -1,23 +1,24 @@

LCD.Clear()
F = EV3File.OpenAppend("testfile.txt")
LCD.Text(1,0,0,1,"Append handle: "+F)
EV3File.WriteLine(F, "this is a test line")
EV3File.Close(F)

F = EV3File.OpenWrite("testfile.txt")
LCD.Text(1,0,16,1,"Write handle: "+F)
LCD.Write(0,0,"Write handle: "+F)
EV3File.WriteLine(F, "dummy text")
EV3File.WriteByte(F, 64)
EV3File.WriteByte(F, 10)
EV3File.Close(F)

F = EV3File.OpenAppend("testfile.txt")
LCD.Write(0,16,"Append handle: "+F)
EV3File.WriteLine(F, "more text")
EV3File.Close(F)

F = EV3File.OpenRead("testfile.txt")
LCD.Text(1,0,32,1,"Read handle: "+F)
LCD.Write(0,32,"Read handle: "+F)
For I=1 To 5
LCD.Text(1,0,32+16*i,1,i+": "+EV3File.ReadLine(F))
LCD.Write(0,32+16*i,i+": "+EV3File.ReadLine(F))
endfor
EV3File.Close(F)

LCD.Text(1,160,90,1,"Done")
LCD.Write(120,112,"Done")
Program.Delay(10000)
File renamed without changes.
2 changes: 1 addition & 1 deletion testsuite/languagefeatures/LargeMemory.sb
@@ -1,4 +1,4 @@
' Test program to chech how much memory is available for variables
' Test program to check how much memory is available for variables

SIZE = 1000000

Expand Down
3 changes: 2 additions & 1 deletion testsuite/languagefeatures/OperatorPrecedence.sb
Expand Up @@ -6,7 +6,8 @@ Assert.Equal(4-10/5, 2, "div before minus")

Assert.Equal(4*5*6/3, 40, "left to right 1")
Assert.Equal(4/2*6, 12, "left to right 2")
Assert.Equal(4/2/2, 1, "left to right 2")
Assert.Equal(4/2/2, 1, "left to right 3")
Assert.Equal(4-3+5, 6, "left to right 4")

If "True" or "False" and "False" Then
' OK
Expand Down

0 comments on commit 71fbe82

Please sign in to comment.