CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Dec 13, 2018 4:50 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
 Post subject: To write a binary file
PostPosted: Fri Nov 30, 2018 7:26 am 
Offline

Joined: Tue Jul 31, 2018 3:36 am
Posts: 7
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 :)


Top
   
PostPosted: Fri Nov 30, 2018 5:30 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
If by binary mode, you mean, accessing bytes, this is what text mode does.
As almost all devices don't run Windows plateforms, this topic suggest it's the same :
https://stackoverflow.com/questions/229924/difference-between-files-written-in-binary-and-text-mode


Top
   
PostPosted: Mon Dec 03, 2018 2:34 am 
Offline

Joined: Tue Jul 31, 2018 3:36 am
Posts: 7
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


Top
   
PostPosted: Mon Dec 03, 2018 3:59 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
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"


Last edited by dFx on Mon Dec 03, 2018 5:26 pm, edited 1 time in total.

Top
   
PostPosted: Mon Dec 03, 2018 4:07 pm 
Offline

Joined: Mon Nov 03, 2014 7:15 am
Posts: 42
Hi eric,

Quote:
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.

Attachment:
Sysfileasync.jpg


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


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Dec 10, 2018 3:16 am 
Offline

Joined: Tue Jul 31, 2018 3:36 am
Posts: 7
Thanks for the reply/suggestions
It's helpful and corrected some of my concept


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited