To write a binary file

eric.lin
2018-11-30
2018-12-10
  • eric.lin - 2018-11-30

    Hi,
    I want to open and write a file in binary mode
    Seems SysFile.lib doesn't support this option, can anyone give me some advice?
    Another question is, what's the difference between SysFile.lib and SysLibFileAsync.lib?
    Thank you very much

     
  • eric.lin - 2018-12-03

    Hi~
    For example, when I write character A
    I want it to be recorded as 01000001(0x41) in binary mode
    And be recorded as A in text mode (ascii mode)
    Can I achieve this with codesys libs ? Thank you

     
  • dFx

    dFx - 2018-12-03

    Please read some ascii and file storing documentation before posting … GIYF

    There are no characters stored in files. Only bits are. ASCII is a way of interpreting those bits.
    so recording "A" character in a file, with text mode or binary mode, as long as you are in ASCII encoding, will produce 01000001(0x41) in your file.

    Then reading it, it will be read bytes per bytes. binary mode and ascii mode. binary mode will show the raw value 0x41 while ASCII will show you decoded ascii char -> "A"

     
  • alwoso - 2018-12-03

    Hi eric,

    Zitat:
    Another question is, what's the difference between SysFile.lib and SysLibFileAsync.lib?

    looking into the documentation area of SysFileAsync you can read, that this library is a "wrapper" for SysFile to handle asynchronous access to file functions. That means, the requested function will be processed in the background, and in your program you have to wait for the result. This may last some time, depending on the function and your hardware etc.

    The big advantage is that your application program is not interrupted by a slow file access, which might cause trouble in your machine.

    Best regards

    Alfred

    IMG: Sysfileasync.jpg

     
  • eric.lin - 2018-12-10

    Thanks for the reply/suggestions
    It's helpful and corrected some of my concept

     

Log in to post a comment.