Author Topic: Writing a null string to EEPROM String Data  (Read 13798 times)

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Writing a null string to EEPROM String Data
« on: March 31, 2013, 10:44:54 PM »
I've run into some difficulty attempting to change values in the EEPROM string data area.  The target PLCs are the Nano-10 and FMD series.

The goal was to write a null string, "", into the EEPROM string data area without having to write, download and execute a .PC6 program.

The first failed attempt was to use Host-link commands in the form of "@01W$000200*<cr>"  This failed with the error message, "@01ER56*<cr>" being returned from the PLC.  It seems that this host-link command is not capable of dealing with a "" message.  

I tried all sorts of games to send a send a single character string where the value of the this character was a &H00.  Host-link commands are not happy with unprintable ASCII.

The second attempt was to use the "PLC Data EEPROM Manager" that was part of i-TRiLOGI V6.45. This program can correctly recognize a null string stored in the EEPROM string data area but is not capable of writing a null string.

As an example if the EEPROM string memory contains a null string for $2, the EEP Buffer window will show the following:

$1,FMD    r79A
$2,
$3,hello
[/color]
If the "Save Buffer to File" button is pressed the .csv file that is created looks like this:

$1,FMD    r79A<LF>
$2,<LF>
$3,hello<LF>
<CR><LF>
[/color]
Now I will change the value of the EEPROM $2 is via a PLC program with the following code:

save_EEP$ "Test String", 2
[/color]
The EEP Buffer window will show:

$1,FMD    r79A
$2,Test String
$3,hello
[/color]
If the .csv file that was created when $2 was a null string, "", is loaded back into the String Buffer Window and then the YELLOW button labeled, "Write EEP Buffers to PLC", then $2 is not changed to a null sting, "". OOPS!

OK now the condensed version of my complaint:

1. The PLC Data EEPROM Manager is capable of reading a null string, "", from EEPROM but is not capable of writing a null string back into EEPROM.  This is very non-symmetrical behavior and is surely a programming error that could be fixed.

2. The Host-link command to write strings to EEPROM is incapable of dealing with a null string. This command has problems with many strings that are legal in TBASIC.  This command can only write strings that are one or more characters in length and do not contain any unprintable ASCII characters.  I don't think that you can fix this as this would require firmware changes.

3.  I suspect that problem #2 is the root cause of why the  EEPROM Manager can't write a null string.  I believe that the EEPROM Manager can be fixed by having it use the "Write EEPROM Integer Data" host link command to force a value of &H00 at the starting location in EEPROM for the specified string.

4. I have a minor gripe with the the .csv format written by the EEPROM Manager.  Microsoft EXCEL will read this file successfully, so my soap box is pretty small.  The gripe, is that the file is created with inconsistent end of line characters.  Most of the lines are terminated  with a line-feed character (UNIX format) but at least two of the lines in the file use the 2 character sequence of carriage return then line-feed (DOS format).  I sure that this is just messy Java programming.

Best Regards,

Gary D.
« Last Edit: April 01, 2013, 05:18:49 PM by garysdickinson »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Writing a null string to EEPROM String Data
« Reply #1 on: April 01, 2013, 02:16:30 PM »
The current WX$ command does appear to ignore the write if the content is an empty string instead of writing an actual empty string to the location. This is a firmware related issue. It could be fixed in a future firmware release. To create a blank string you can try to write a single space character or special character instead of writing a blank string. This will be the best workaround for now.  

The PLC uses null character (ASCII 0) as the string terminator and therefore null character cannot be embedded into the HOSTLINK command.

Regarding the CSV file created by the EEPROM manager, there is no problem importing it into Excel spreadsheet typically so there wasn't a lot of attention paid to the "purity" of the output. However, we will certainly consider fixing it in the next i-TRiLOGI release.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Writing a null string to EEPROM String Data
« Reply #2 on: April 01, 2013, 05:15:28 PM »
Thanks for confirming my thoughts on the WX$ host-link command.

I have been using a crude workaround for the "PLC Data EEPROM Manager" in iTRiLOGI.  In the Integer EEP Buffer window I enter:

1005,&H000
985,&H0000
965,&H0000

In the String EEP Buffer Window I enter:

$1,FMD    r79A
$2,
$3,hello

When I click on the "Write EEP Buffers to PLC" button the Integer EEP Buffer is written first followed by the String EEP Buffer.  The writes to the Integer EEP buffer, force the first 3 strings to "".  The writing of the String EEP Buffer updates those strings that are not null, "".

I attempted to attach a ".jpg" screen shot of this workaround, but the current version of the YaBBSE crashes with the following error message:

2: opendir(/usr/shared/web/triplc/yabbse/attachments) [function.opendir]: failed to open dir: No such file or directory
(/home/triplc/public_html/yabbse/Sources/Post.php ln 901)


I suspect that this issue is a side effect of the changes to the website.  The Technical support forum works much better if you start from the old website www.tri-plc.com

If you start from the "new" website,  www.triplc.com the forum is very awkward.    I'm guessing that the "new" website is treating my desktop PC as if it were a mobile device.

Thanks again,

Gary D.
« Last Edit: April 01, 2013, 05:25:53 PM by garysdickinson »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Writing a null string to EEPROM String Data
« Reply #3 on: April 02, 2013, 10:05:04 AM »
Thank you for your feedback. The new website is still in testing phase so there are bugs that we need to fix. Please continue to visit the current website www.tri-plc.com. The reason we are re-directing the link for the forum from the current website to the new website is to allow a chance to test the new forum for bugs (such as what you have discovered) and also not to maintain two separate databases.

The uploading issue has been fixed. It was caused by the wrong attachment folder path name which was transferred from current website to the new website and the two sites are not using the same file structure. We have tested it and managed to post a JPG file.
« Last Edit: April 02, 2013, 10:06:08 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Writing a null string to EEPROM String Data
« Reply #4 on: April 02, 2013, 10:14:34 AM »
Test posting
Email: support@triplc.com
Tel: 1-877-TRI-PLCS