saving bike and bpm data in separate files

This commit is contained in:
shinichi
2020-09-30 14:17:26 +02:00
parent 6f1ab57fe4
commit 82f2d6b71c
2 changed files with 37 additions and 7 deletions

View File

@@ -129,8 +129,19 @@ namespace Server
}
else if (DataParser.isRawData(message))
{
Console.WriteLine(BitConverter.ToString(message));
saveData.WriteDataRAW(message);
Console.WriteLine(BitConverter.ToString(payloadbytes));
if (payloadbytes.Length == 8)
{
saveData.WriteDataRAWBike(payloadbytes);
}
else if (payloadbytes.Length == 2)
{
saveData.WriteDataRAWBPM(payloadbytes);
}
else
{
Console.WriteLine("received raw data with weird lenght " + BitConverter.ToString(payloadbytes));
}
}

View File

@@ -31,22 +31,41 @@ namespace Server
}
}
public void WriteDataRAW(byte[] data)
public void WriteDataRAWBPM(byte[] data)
{
int length = 0;
try
{
FileInfo fi = new FileInfo(this.path + "/raw" + filename + ".bin");
FileInfo fi = new FileInfo(this.path + "/rawBPM" + filename + ".bin");
length = (int)fi.Length;
}
catch
{
// do nothing
}
using (BinaryWriter sw = new BinaryWriter(File.Open(this.path + "/raw" + filename + ".bin", FileMode.Create)))
using (BinaryWriter sw = new BinaryWriter(File.Open(this.path + "/rawBPM" + filename + ".bin", FileMode.Create)))
{
sw.Seek(length, SeekOrigin.End);
sw.Write(data);
sw.Flush();
}
}
Console.WriteLine("head position " + sw.Seek(length, SeekOrigin.End));
public void WriteDataRAWBike(byte[] data)
{
int length = 0;
try
{
FileInfo fi = new FileInfo(this.path + "/rawBike" + filename + ".bin");
length = (int)fi.Length;
}
catch
{
// do nothing
}
using (BinaryWriter sw = new BinaryWriter(File.Open(this.path + "/rawBike" + filename + ".bin", FileMode.Create)))
{
sw.Seek(length, SeekOrigin.End);
sw.Write(data);
sw.Flush();
}