RobotStudio event

Raw bytes reading error

egor
egor
edited June 2019 in RAPID Programming
Can't understand why I'm getting the following error: "End of file was found before all bytes were read in ReadRawBytes". I tried a plenty of examples from manuals and there is always the same error... How it is possible to reach the EOF and not read all bytes in the text file?

    PROC rawbytes_test()
        VAR iodev io_device;
        VAR rawbytes raw_data_in;
        VAR rawbytes raw_data_out;
        VAR num float:=15.2;
        VAR num answer;

        ClearRawBytes raw_data_out;
        ClearRawBytes raw_data_in;
        PackRawBytes float,raw_data_out,(RawBytesLen(raw_data_out)+1)\Float4;
        Open "HOME:"\File:="Test.txt",io_device\Bin;
        WriteRawBytes io_device,raw_data_out;

        !Error appears on this line
        ReadRawBytes io_device,raw_data_in\Time:=1;
        Close io_device;
        UnpackRawBytes raw_data_in,1,answer\Float4;
    ENDPROC

Best Answer

Answers

  • lemster68
    lemster68 ✭✭✭
    Is this just an ascii text file?  I never used ReadRawBytes but I have read and written to files using Open instruction, default is ascii.
    Lee Justice
  • lemster68 said:
    Is this just an ascii text file?  I never used ReadRawBytes but I have read and written to files using Open instruction, default is ascii.
    Yes, it's just an ASCII empty file, which is created by controller.