saving bike and bpm data in separate files
This commit is contained in:
@@ -129,8 +129,19 @@ namespace Server
|
|||||||
}
|
}
|
||||||
else if (DataParser.isRawData(message))
|
else if (DataParser.isRawData(message))
|
||||||
{
|
{
|
||||||
Console.WriteLine(BitConverter.ToString(message));
|
Console.WriteLine(BitConverter.ToString(payloadbytes));
|
||||||
saveData.WriteDataRAW(message);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,22 +31,41 @@ namespace Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteDataRAW(byte[] data)
|
public void WriteDataRAWBPM(byte[] data)
|
||||||
{
|
{
|
||||||
int length = 0;
|
int length = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileInfo fi = new FileInfo(this.path + "/raw" + filename + ".bin");
|
FileInfo fi = new FileInfo(this.path + "/rawBPM" + filename + ".bin");
|
||||||
length = (int)fi.Length;
|
length = (int)fi.Length;
|
||||||
}
|
}
|
||||||
catch
|
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.Write(data);
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user