Skip to content

Commit 5d2578a

Browse files
committed
-f extended with full msgformat specification including binary
1 parent d8802c6 commit 5d2578a

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

Source/IO/File.h

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ namespace IO
3030
bool append_mode = true;
3131

3232
public:
33+
FileOutput() : OutputMessage() { fmt = MessageFormat::NMEA; }
34+
3335
~FileOutput()
3436
{
3537
Stop();
@@ -53,16 +55,41 @@ namespace IO
5355

5456
void Receive(const AIS::Message *data, int len, TAG &tag)
5557
{
56-
for (int i = 0; i < len; i++)
58+
if (fmt == MessageFormat::NMEA)
5759
{
58-
if (filter.include(data[i]))
60+
for (int i = 0; i < len; i++)
5961
{
60-
for (const std::string &s : data[0].NMEA)
62+
if (!filter.include(data[i]))
63+
continue;
64+
65+
for (const auto &s : data[i].NMEA)
6166
{
6267
file << s << std::endl;
6368
}
6469
}
6570
}
71+
else if (fmt == MessageFormat::BINARY_NMEA)
72+
{
73+
for (int i = 0; i < len; i++)
74+
{
75+
if (!filter.include(data[i]))
76+
continue;
77+
78+
std::string binary_packet = data[i].getBinaryNMEA(tag);
79+
file.write(binary_packet.c_str(), binary_packet.length());
80+
}
81+
}
82+
else
83+
{
84+
for (int i = 0; i < len; i++)
85+
{
86+
if (!filter.include(data[i]))
87+
continue;
88+
89+
file << data[i].getNMEAJSON(tag.mode, tag.level, tag.ppm, tag.status, tag.hardware, tag.version, tag.driver, false, tag.ipv4, "") << std::endl;
90+
}
91+
}
92+
6693
if (file.fail())
6794
{
6895
Error() << "File: cannot write to file.";

0 commit comments

Comments
 (0)