Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace recParser
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*gamiee has been here ^^*/
- BinaryReader br = new BinaryReader(File.OpenRead("ais_2013-06-20_190159.rec"));
- while (br.BaseStream.Position != br.BaseStream.Length)
- {
- byte[] header = br.ReadBytes(2); //precita 2 byte
- Array.Reverse(header); //otoci kvoli big endianu
- byte[] goodHeader = { 255, 255 }; //0xFFFF
- if (!header.SequenceEqual(goodHeader)) //porovnava headre
- {
- Console.WriteLine("Wrong header!");
- Console.ReadLine();
- }
- //timestamp by mal mat asi 4byte?!?
- byte[] time = br.ReadBytes(4);
- Array.Reverse(time);
- Int32 timestamp = BitConverter.ToInt32(time, 0);
- //ziskat datetime z unixoveho timestampu ide troska inak v c#
- DateTime datetime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- datetime = datetime.AddSeconds(timestamp);
- //dlzka
- byte[] dataLenght = br.ReadBytes(2);
- Array.Reverse(dataLenght);
- Int16 dataLen = BitConverter.ToInt16(dataLenght, 0);
- byte[] data = br.ReadBytes(dataLen);
- Array.Reverse(data);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement