Fix bug with the frame sink blocks

* Change clear text format to binary
* Add binary and hex annotated
This commit is contained in:
Nikos Karamolegkos 2018-02-02 20:03:14 +02:00
parent c19524aa6b
commit 909ae9da78
4 changed files with 14 additions and 15 deletions

View File

@ -21,15 +21,15 @@
<key>output_type</key>
<type>enum</type>
<option>
<name>Clear Text</name>
<name>Binary</name>
<key>0</key>
</option>
<option>
<name>Hex</name>
<name>Hex annotated</name>
<key>1</key>
</option>
<option>
<name>Binary</name>
<name>Binary annotated</name>
<key>2</key>
</option>
</param>

View File

@ -10,15 +10,15 @@
<key>format</key>
<type>enum</type>
<option>
<name>Clear Text</name>
<name>Binary</name>
<key>0</key>
</option>
<option>
<name>Hex</name>
<name>Hex annotated</name>
<key>1</key>
</option>
<option>
<name>Binary</name>
<name>Binary annotated</name>
<key>2</key>
</option>

View File

@ -105,8 +105,7 @@ namespace gr
{
case 0:
{
/* add .txt to filename */
filename.append (".txt");
/* Binary form */
std::ofstream fd (filename.c_str ());
fd.write ((const char *) pmt::blob_data (msg),
pmt::blob_length (msg));
@ -115,8 +114,8 @@ namespace gr
}
case 1:
{
/* add .hex to filename */
filename.append (".hex");
/* aHex annotated, dd .txt to filename */
filename.append (".txt");
std::ofstream fd (filename.c_str ());
su = (uint8_t *) pmt::blob_data (msg);
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
@ -128,8 +127,8 @@ namespace gr
}
case 2:
{
/* add .bin to filename */
filename.append (".bin");
/* Binary annotated, add .txt to filename */
filename.append (".txt");
std::ofstream fd (filename.c_str ());
su = (uint8_t *) pmt::blob_data (msg);
for (size_t i = 0; i < pmt::blob_length (msg); i++) {

View File

@ -99,13 +99,13 @@ namespace gr
switch (d_format)
{
case 0:
case 0: // binary
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
std::cout << s[i];
}
std::cout << std::endl;
break;
case 1:
case 1: // hex annotated
su = (uint8_t *) pmt::blob_data (msg);
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
std::cout << std::hex << std::showbase << std::setw (4)
@ -113,7 +113,7 @@ namespace gr
}
std::cout << std::endl;
break;
case 2:
case 2: // binary annotated
su = (uint8_t *) pmt::blob_data (msg);
for (size_t i = 0; i < pmt::blob_length (msg); i++) {
std::cout << "0b" << std::bitset<8> (su[i]) << " ";