reading a protocol buffer file -- what header should i skip?
hi

i have a file which is a dnstap file captured using the fstrm-capture [log file github](https://github.com/hvram1/dnstaplogfile/blob/main/dnstap.log) .

i am able to read the file but when i try to process it i get an error

the proto definition is present here [.proto definition github](https://github.com/dnstap/dnstap.pb/blob/master/dnstap.proto) .

i have the following code that tries to read the file and print the p…
from here [fstrm python receiver](https://github.com/dmachard/python-framestream/blob/main/fstrm/fstrm_codec.py)

# frame streams control frame format - data frame length equals 00 00 00 00

# |||

# | data frame length | 4 bytes |

# ||…
It' just standard c++ ifstream and ofstream. When the program starts, try to open the file, if it success then read it. [image] dueck456:

is there an easy way to detect when new code is flashed to the device so i can reinitialize the retained variables?

below is a link to a post by [@rickkas7](/u/rickkas7) about storing retained data in a struct.

[image] dueck456:

saving a know value to eeprom jumps to mind

there is … even if you get the binary contents, decoding it is quite the undertaking. you can find the format specs here if you want to try it, though:

[image]

[png specification: file structure](http://www.libpng.org/pub/png/spec/1.2/png-structure.html)

there are existing implementations in lua, such as [this one](https://github.com/delusionallogic/pnglua), but they don’t cove… hi,

[image] felixch:

there is no memory copy in nvbuffer except explicit call nvbuffertransform or nvbuffer2raw?

nvbuffertransform() is to copy nvbuffer to nvbuffer. it is hardware memory copy. nvbuffer2raw() is to copy nvbuffer to cpu buffer. it is software memory copy.

[image] felixch:

… I have the same problem and added this to the DbContext:



```
private void PrintStackTrace()
{
  var st = new StackTrace();
  foreach (var sf in st.GetFrames())
    Console.WriteLine($"{sf.GetMethod().DeclaringType.Assembly.GetName().Name} {sf.GetMethod().DeclaringType.Name} {sf.GetMethod().Name}");
}

```

and call this function in the contructor and Dispose of the DbContext.


It seems to be a problem, if the DbContext is added with scoped lifetime to the dependency injection. I filed an issue for that.


<https://github.com/aspnet/EntityFrameworkCore/issues/10693> > 
> My question is when does this function works improperly and why?
> 
> 
> 


Technically it works improperly when you call it with an input stream or an update stream in input mode. That is, if you use fopen() with a "w" mode, or a "+" mode and you're currently in the process of reading from the stream, or stdin.


In practice, all of the above situations are okie dokie *iff* the compiler supports them (and some do, including Borland and Microsoft compilers). In terms of best practice, fflush() on an input stream is frowned upon.


However, note that calling fflush() on an output stream is both well defined and recommended for things such as forcing a user prompt to display, well...promptly. :)



> 
> Nowadays I use scanf("[^\n]") to flush input stream. Is this ok?
> 
> 
> 


Close. The correct call for scanf() to read up to a newline would be:



```
scanf("%*[^\n]");

```

This isn't complete though, because the newline will still be in the stream. You still need to extract it. One way would be to add an ignored character match in the format string:



```
scanf("%*[^\n]%*c");

```

This might not be as flexible though, if you want to do other stuff like count discarded characters. Another way would be to call getchar() after scanf():



```
scanf("%*[^\n]");
getchar();

```

Finally, there's the far more common (and faster!) method of calling getchar() in a loop. I'll even give you a function that you can call instead of having to write it ad hoc every time:



```
#include <stdio.h>

void clear_line(FILE *in)
{
    int ch;

    /* Do nothing if the stream is in an error state */
    if (ferror(in))
        return;

    /* Make sure any end-of-file  state is cleared */
    clearerr(in);

    /* Extract and discard up to a newline or end-of-file */
    do
        ch = getc(in);
    while (ch != '\n' && ch != EOF);

    /*
        Clear an end-of-file state if we stoped on EOF,
        but leave any legitimate error state for the caller
    */
    if (!ferror(in))
        clearerr(in);
}

```

Note that even this solution is incomplete when compared with what people expect from `fflush(stdin)` because it blocks for input when the stream is empty. fflush(), when flushing input streams is supported, will return without blocking on an empty stream. Unfortunately, there's no portable way to emulate that behavior, but it's fairly simple to just ensure that the stream is never empty when calling clear\_line().



> 
> fflush( std::cout );
> 
> 
> 


Yeah, that won't work. fflush() expects a pointer to FILE, not an std::ostream object. std::ostream has its own flush() member for synchronizing with the destination device.


It's also quite silly to flush cout explicitly prior to accepting input through cin because the two are tied together. As soon as you request input from cin, the tied stream (cout) is automatically flushed. Doing it yourself explicitly isn't harmful, but it *is* redundant.


It's actually a pretty nifty feature of the iostream library. Read more about it starting [here](http://www.cplusplus.com/reference/iostream/ios/tie/). please see the above video to learn more. to ask any questions on the content covered in this tutorial please start a new topic within the forum. you may check this how-to guide for reference - [how to use the enterprise dna support forum](https://forum.enterprisedna.co/t/how-to-use-the-enterprise-dna-support-forum/3951) another prevention method i use = fsrminstructions can be found at: http://jpelectron.com/stopcrypto please see the above link to learn more. to ask any questions on the content covered in this tutorial please start a new topic within the forum. you may check this how to guide for reference - [how to use the enterprise dna support forum](https://forum.enterprisedna.co/t/how-to-use-the-enterprise-dna-support-forum/3951) you have to forward the sip and rtp ports of the snom. (before the update this was done by a sip application layer gateway, but we had to remove this because it breaks security.)

[image]

[security announcement: mitigating nat slipstreaming - the ipfire blog](https://blog.ipfire.org/post/security-announcement-mitigating-nat-slipstreaming)

last autumn, we learned about …