2021-03-07 12:46:25 +01:00
|
|
|
/**********************************************************************
|
2022-03-20 20:56:32 +01:00
|
|
|
* This file is used for testing random stuff without running the
|
2021-03-07 12:46:25 +01:00
|
|
|
* whole of SatDump, which comes in handy for debugging individual
|
|
|
|
|
* elements before putting them all together in modules...
|
2022-03-20 20:56:32 +01:00
|
|
|
*
|
|
|
|
|
* If you are an user, ignore this file which will not be built by
|
2021-05-12 21:16:53 +02:00
|
|
|
* default, and if you're a developper in need of doing stuff here...
|
2021-03-07 12:46:25 +01:00
|
|
|
* Go ahead!
|
2022-03-20 20:56:32 +01:00
|
|
|
*
|
2021-03-07 12:46:25 +01:00
|
|
|
* Don't judge the code you might see in there! :)
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
2022-03-28 11:51:13 +02:00
|
|
|
#include "logger.h"
|
2023-12-29 17:08:58 +01:00
|
|
|
#include <fstream>
|
2023-12-31 22:51:40 +01:00
|
|
|
#include <cstring>
|
|
|
|
|
#include "common/image/image.h"
|
2023-12-29 17:08:58 +01:00
|
|
|
|
|
|
|
|
int main(int /*argc*/, char *argv[])
|
2023-11-13 01:28:14 +01:00
|
|
|
{
|
2023-11-13 15:41:02 +01:00
|
|
|
initLogger();
|
2023-11-19 16:22:39 -05:00
|
|
|
completeLoggerInit();
|
2023-12-29 17:08:58 +01:00
|
|
|
|
|
|
|
|
std::ifstream data_in(argv[1], std::ios::binary);
|
|
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
std::vector<uint8_t> img_vector;
|
2023-12-29 17:08:58 +01:00
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
while (!data_in.eof())
|
2023-12-29 17:08:58 +01:00
|
|
|
{
|
2023-12-31 22:51:40 +01:00
|
|
|
uint8_t frm[70];
|
|
|
|
|
data_in.read((char *)frm, 70);
|
2023-12-29 17:08:58 +01:00
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
if (frm[4] == 0x02)
|
2023-12-29 17:08:58 +01:00
|
|
|
{
|
|
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
uint16_t hdr = frm[4 + 1] << 8 | frm[4 + 0];
|
|
|
|
|
uint8_t data_size = frm[4 + 2];
|
|
|
|
|
uint16_t msg_type = frm[4 + 4] << 8 | frm[4 + 3];
|
|
|
|
|
uint16_t pkt_offset = frm[4 + 6] << 8 | frm[4 + 5];
|
2023-12-29 17:08:58 +01:00
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
logger->trace(pkt_offset);
|
2023-12-29 17:08:58 +01:00
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
int new_size = pkt_offset + 56;
|
|
|
|
|
if (img_vector.size() < new_size)
|
|
|
|
|
img_vector.resize(new_size);
|
2023-12-29 17:08:58 +01:00
|
|
|
|
2023-12-31 22:51:40 +01:00
|
|
|
memcpy(&img_vector[pkt_offset], &frm[4 + 8], 56);
|
2023-12-29 17:08:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-12-31 22:51:40 +01:00
|
|
|
|
|
|
|
|
image::Image<uint8_t> img_final;
|
|
|
|
|
img_final.load_jpeg(img_vector.data(), img_vector.size());
|
|
|
|
|
img_final.save_png("strato.png");
|
2023-07-23 23:13:13 +02:00
|
|
|
}
|