Skip to content

XX_finslib_decode_address problem #2

@makay68g

Description

@makay68g

The function does not decode addresses like E0_, E1_, ... , E9_. The following patch corrects this problem:

diff -p -r -b /tmp/libfins-master/src/fins_decode.c libfins-master/src/fins_decode.c
*** /tmp/libfins-master/src/fins_decode.c 2016-12-25 23:39:34.000000000 +0000
--- libfins-master/src/fins_decode.c 2018-09-12 07:10:03.429244324 +0000


*** 32,37 ****
--- 32,38 ----

  • for use with devices over the Omron FINS protocol.
    */
  • #include <string.h>
    #include <ctype.h>
    #include "fins.h"

*************** bool XX_finslib_decode_address( const ch
*** 66,77 ****
--- 67,87 ----

    while ( isspace( *ptr ) ) ptr++;
  •   if (strchr(ptr,'_') && (strchr(ptr,'_')-ptr < 3))
    
  •   {
    
  •       num_char = strchr(ptr,'_')-ptr+1;
    
  •       strncpy(name,ptr,num_char);
    
  •       ptr = strchr(ptr,'_')+1;
    
  •   }
    
  •   else
    
  •   {
          while ( isalpha( *ptr ) &&  num_char < 3 ) {
    
              name[num_char] = (char) toupper( *ptr );
              num_char++;
              ptr++;
          }
    
  •   }
      if ( isalpha( *ptr ) ) return true;
    
      while ( num_char < 4 ) name[num_char++] = 0;
    

============================================

Also, the C1M, C1S, C02, C01, C22 addresses are not decoded correctly, but since I do not use them I did not patch the program for those.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions