-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
552 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
// Port of https://github.com/sccn/liblsl/blob/master/testing/lslver.c | ||
using SharpLSL; | ||
using SharpLSL.Interop; | ||
|
||
namespace LSLVer | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine($"LSL version: {LSL.lsl_library_version()}"); | ||
Console.WriteLine(Lsl.GetLibraryInfo()); | ||
Console.WriteLine(Lsl.GetLocalClock()); | ||
Console.WriteLine($"LSL version: {LSL.GetLibraryVersion()}"); | ||
Console.WriteLine(LSL.GetLibraryInfo()); | ||
Console.WriteLine(LSL.GetLocalClock()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace SharpLSL | ||
{ | ||
public class LostException : LSLException | ||
{ | ||
public LostException() | ||
{ | ||
} | ||
|
||
public LostException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
public LostException(string message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,66 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
using SharpLSL.Interop; | ||
using static SharpLSL.Interop.LSL; | ||
|
||
namespace SharpLSL | ||
{ | ||
public static class Lsl | ||
public static class LSL | ||
{ | ||
public const double IrregularRate = LSL_IRREGULAR_RATE; | ||
|
||
public const double DeducedTimestamp = LSL_DEDUCED_TIMESTAMP; | ||
|
||
public const double Forever = LSL_FOREVER; | ||
|
||
public const int NoPreference = LSL_NO_PREFERENCE; | ||
|
||
public static string GetLastError() | ||
{ | ||
var ptr = LSL.lsl_last_error(); | ||
return Marshal.PtrToStringAnsi(ptr); | ||
var ptr = lsl_last_error(); | ||
return Marshal.PtrToStringAnsi(ptr); // TODO: Encoding | ||
} | ||
|
||
public static int GetProtocolVersion() => LSL.lsl_protocol_version(); | ||
public static int GetProtocolVersion() => lsl_protocol_version(); | ||
|
||
public static int GetLibraryVersion() => LSL.lsl_library_version(); | ||
public static int GetLibraryVersion() => lsl_library_version(); | ||
|
||
public static string GetLibraryInfo() | ||
{ | ||
var ptr = LSL.lsl_library_info(); | ||
return Marshal.PtrToStringAnsi(ptr); | ||
var ptr = lsl_library_info(); | ||
return Marshal.PtrToStringAnsi(ptr); // TODO: Encoding | ||
} | ||
|
||
public static double GetLocalClock() => LSL.lsl_local_clock(); | ||
public static double GetLocalClock() => lsl_local_clock(); | ||
|
||
public static void DestroyString(IntPtr str) => LSL.lsl_destroy_string(str); | ||
// TODO: Remove | ||
//public static void DestroyString(IntPtr str) => LSL.lsl_destroy_string(str); | ||
|
||
#if !NET35 | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
#endif | ||
internal static void CheckError(int errorCode) | ||
{ | ||
if (errorCode < 0) | ||
{ | ||
switch ((lsl_error_code_t)errorCode) | ||
{ | ||
case lsl_error_code_t.lsl_no_error: | ||
break; | ||
case lsl_error_code_t.lsl_timeout_error: | ||
throw new TimeoutException("The operation failed due to a timeout."); | ||
case lsl_error_code_t.lsl_lost_error: | ||
throw new LostException("The stream has been lost."); | ||
case lsl_error_code_t.lsl_argument_error: | ||
throw new ArgumentException("An argument was incorrectly specified."); | ||
case lsl_error_code_t.lsl_internal_error: | ||
throw new LSLException("An internal error has occurred."); | ||
default: | ||
throw new LSLException("An unknown error has occurred."); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using SharpLSL.Interop; | ||
using static SharpLSL.Interop.LSL; | ||
|
||
namespace SharpLSL | ||
{ | ||
public class StreamInlet | ||
{ | ||
} | ||
} |
Oops, something went wrong.