new node iso8583 with dependencies - I need some help

178 views
Skip to first unread message

acoliveira Oliveira

unread,
Aug 16, 2017, 2:58:53 PM8/16/17
to Node-RED
Sorry for my poor english,

I recept this message below(2), (cannot find iso-8583), and use this for install(1)

1) - First install iso-8583 module

C:\vs02\vs-h6>npm i -g --save iso-8583

> iso-...@1.0.4 install C:\Program Files (x86)\nodejs\node_modules\iso-8583
> node-gyp rebuild


C:\Program Files (x86)\nodejs\node_modules\iso-8583>if not defined npm_config_node_gyp (node "C:\PROGRA~2\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Compilando os projetos desta solução um de cada vez. Para habilitar o build paralelo, adicione a opção "/m".
  NativeExtension.cc
  functions.cc
  win_delay_load_hook.cc
  dl_iso8583.c
  dl_iso8583_common.c
  dl_iso8583_defs_1987.c
  dl_iso8583_defs_1993.c
  dl_iso8583_fields.c
  dl_mem.c
  dl_output.c
  dl_str.c
  dl_time.c
  dl_timer.c
..\lib\dl_str.c(132): warning C4013: 'toupper' indefinido; assumindo extern ret
ornando int [C:\Program Files (x86)\nodejs\node_modules\iso-8583\build\ISO8583.
vcxproj]
..\lib\dl_str.c(546): warning C4244: 'função': conversão de '__int64' para 'DL_
UINT32', possível perda de dados [C:\Program Files (x86)\nodejs\node_modules\is
o-8583\build\ISO8583.vcxproj]
     Criando biblioteca C:\Program Files (x86)\nodejs\node_modules\iso-8583\bui
  ld\Release\ISO8583.lib e objeto C:\Program Files (x86)\nodejs\node_modules\is
  o-8583\build\Release\ISO8583.exp
  Gerando c¾digo
  Finalizada a geraþÒo de c¾digo
  ISO8583.vcxproj -> C:\Program Files (x86)\nodejs\node_modules\iso-8583\build\
  Release\\ISO8583.node
  ISO8583.vcxproj -> C:\Program Files (x86)\nodejs\node_modules\iso-8583\build\
  Release\ISO8583.pdb (Full PDB)
+ iso-...@1.0.4
updated 1 package in 20.729s

C:\vs02\vs-h6>

1.1) and use this file below for test iso-8583 module

===================================
teste.js
//https://github.com/s-a/iso-8583

var fs = require('fs');
var ISO8583 = require('iso-8583');
console.log( 'Envio \n' )

    /*
var msgS2 = [
        [0  , "0800"],
        [2  , "454000000000003"],
        [3  , "000000"],
        [11 , "000001"],
        [12 , "0000"],
        [13 , "0101"],
        [14 , "0505"],
        [15 , "0202"],
        [28 , "C1200"],
        [34 , "12345"],
        [41 , "12345678"],
        [42 , "123456789012345"],
        [60 , "TEST DATA"],
        [61 , "LONGER TEST DATA"],
        [62 , "The quick brown fox jumped over the lazy dog"]
        ,[70 , "301"]
    ]; */
  
var msgS2 = [
        [0, "0200"],
        [2, "60197105032103634"],
        [3, "001000"],
        [4, "15075"],
        [7, "0429104720"],
        [11, "456"],
        [12, "112233"],
        [41, "44449999"],
        [22, "02"]
        ,[125, "BLAH BLAH"]
    ];
console.dir( msgS2);
var messageS2 = new ISO8583.Message();
var packedMessageS2 = messageS2.packSync(msgS2);
console.log(packedMessageS2);

var _msg ='';
for (var x = 0 ; x < packedMessageS2.length ; x++) {
    _msg = _msg + packedMessageS2[ x ];
}

console.log('\n\nMSG:' + _msg);

fs.writeFile("./msg.txt", _msg , function(err) {
    if(err) {
        return console.log(err);
    }
    console.log("The file was saved!\n\n"  );
});

var msgR = new Buffer( _msg, "hex");
var lenR = msgR.length;
var messageR = new ISO8583.Message();
var unpackedMessageR = messageR.unpackSync(msgR, lenR);
console.log('\ntamanho:'+ unpackedMessageR.length + ' \n');
console.log(unpackedMessageR);

json_str = JSON.stringify(unpackedMessageR);

fs.writeFile("./arq.json", json_str, function(err) {
    if(err) {
        return console.log(err);
    }

    console.log("The file was saved!\n\n"  );
});

console.log('\ntamanho:'+ unpackedMessageR.length + ' \n');
for( var x=0; x < unpackedMessageR.length; x++){
    if (unpackedMessageR[x]) {
       console.log( 'key:' + unpackedMessageR[x].key + '  Value:' +  unpackedMessageR[x].value);
    }
}

1.2) This sample works!
C:\vs02\vs-h6>node teste.js
Envio

[ [ 0, '0200' ],
  [ 2, '60197105032103634' ],
  [ 3, '001000' ],
  [ 4, '15075' ],
  [ 7, '0429104720' ],
  [ 11, '456' ],
  [ 12, '112233' ],
  [ 41, '44449999' ],
  [ 22, '02' ],
  [ 125, 'BLAH BLAH' ] ]
[ '02',
  '00',
  'F2',
  '30',
  '04',
  '00',
  '00',
  '80',
  '00',
  '00',
  '00',
  '00',
  '00',
  '00',
  '00',
  '00',
  '00',
  '08',
  '17',
  '06',
  '01',
  '97',
  '10',
  '50',
  '32',
  '10',
  '36',
  '34',
  '00',
  '10',
  '00',
  '00',
  '00',
  '00',
  '01',
  '50',
  '75',
  '04',
  '29',
  '10',
  '47',
  '20',
  '00',
  '04',
  '56',
  '11',
  '22',
  '33',
  '00',
  '02',
  '34',
  '34',
  '34',
  '34',
  '39',
  '39',
  '39',
  '39',
  '00',
  '09',
  '42',
  '4C',
  '41',
  '48',
  '20',
  '42',
  '4C',
  '41',
  '48' ]


MSG:0200F2300400008000000000000000000008170601971050321036340010000000000150750429104720000456112233000234343434393939390009424C414820424C4148

tamanho:126

[ { key: '0', value: '0200' },
  ,
  { key: '2', value: '60197105032103634' },
  { key: '3', value: '001000' },
  { key: '4', value: '000000015075' },
  ,  ,
  { key: '7', value: '0429104720' },
  ,  ,  ,
  { key: '11', value: '000456' },
  { key: '12', value: '112233' },
  ,  ,  ,  ,  ,  ,  ,  ,  ,
  { key: '22', value: '002' },
  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,
  { key: '41', value: '44449999' },
  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  , ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,
  ... 26 more items ]

tamanho:126

key:0  Value:0200
key:2  Value:60197105032103634
key:3  Value:001000
key:4  Value:000000015075
key:7  Value:0429104720
key:11  Value:000456
key:12  Value:112233
key:22  Value:002
key:41  Value:44449999
key:125  Value:BLAH BLAH
The file was saved!

The file was saved!

C:\vs02\vs-h6>

2) Node-Red Exec screen

C:\vs02\vs-h6>node-red -u c:\vs02\vs-h6
16 Aug 14:24:24 - [info]

Welcome to Node-RED
===================

16 Aug 14:24:24 - [info] Node-RED version: v0.17.5
16 Aug 14:24:24 - [info] Node.js  version: v6.11.0
16 Aug 14:24:24 - [info] Windows_NT 10.0.15063 x64 LE
16 Aug 14:24:25 - [info] Loading palette nodes
16 Aug 14:24:32 - [warn] ------------------------------------------------------
16 Aug 14:24:32 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
16 Aug 14:24:32 - [warn] [tail] Not currently supported on Windows.
16 Aug 14:24:32 - [warn] [Iso8583] Error: Cannot find module 'iso-8583'                                     <<<<<<<<---------------------
16 Aug 14:24:32 - [warn] ------------------------------------------------------
16 Aug 14:24:32 - [info] Settings file  : c:\vs02\vs-h6\settings.js
16 Aug 14:24:32 - [info] User directory : c:\vs02\vs-h6
16 Aug 14:24:32 - [info] Flows file     : c:\vs02\vs-h6\flows_acoliveira.json
16 Aug 14:24:32 - [info] Starting flows

source modules:

============================================
package.json:
{
  "name": "node-red-contrib-node-iso8583",
  "requires": true,
  "dependencies": {
    "bindings": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
      "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw=="
    },
    "iso-8583": {
      "version": "1.0.4",
      "resolved": "https://registry.npmjs.org/iso-8583/-/iso-8583-1.0.4.tgz",
      "integrity": "sha1-Uge+OYY5JT4aD22fg4ZpyJvyVS4=",
      "requires": {
        "bindings": "1.3.0",
        "nan": "2.6.2"
      }
    },
    "nan": {
      "version": "2.6.2",
      "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz",
      "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U="
    }
  },
  "node-red": {
    "nodes": {
      "Iso8583": "wrapper_iso8583.js"
    }
  }
}

============================================
wrapper_iso8583.js
module.exports = function(RED) {
    "use strict";
    var ISO8583 = require('iso-8583');
  
    function Iso8583Node(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.on('input', function(msg) {
            var messageS2 = new ISO8583.Message();
            var msgS2 = msg.payload;
          
            if (msgS2 instanceof Array) { // monta iso8583 com array, devolvendo string
                var packedMessageS2 = messageS2.packSync(msgS2);
                var _msg ='';
                for (var x = 0 ; x < packedMessageS2.length ; x++) {
                    _msg = _msg + packedMessageS2[ x ];
                }
                msg.payload = _msg;
            } else {
                var msgR = new Buffer( msgS2, "hex"); // desmonta iso8583 do texto, devolvendo array
                var lenR = msgR.length;
                var unpackedMessageR = messageS2.unpackSync(msgR, lenR);
                msg.payload = unpackedMessageR;
            }
            node.send(msg);
        });
    }
    RED.nodes.registerType("Iso-8583",Iso8583Node);
}

============================================
wrapper_iso8583.html
<script type="text/javascript">
    RED.nodes.registerType('Iso-8583',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""}
        },
        inputs:1,
        outputs:1,
        icon: "file.png",
        label: function() {
            return this.name||"Iso-8583";
        }
    });
</script>

<script type="text/x-red" data-template-name="Iso-8583">
    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
</script>

<script type="text/x-red" data-help-name="Iso-8583">
    <p>A simple node that converts the message payloads into/from Iso-8583 characters</p>
</script>

============================================
and i use this for test


C:\vs02\nodered\node-contribu-node-iso8583>npm link
npm WARN node-red-contrib-node-iso8583@ No description
npm WARN node-red-contrib-node-iso8583@ No repository field.
npm WARN node-red-contrib-node-iso8583@ No license field.

up to date in 0.204s
C:\Program Files (x86)\nodejs\node_modules\node-red-contrib-node-iso8583 -> C:\vs02\nodered\node-contribu-node-iso8583

C:\vs02\nodered\node-contribu-node-iso8583>

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

C:\Users\milnishi\.node-red>npm link node-red-contrib-node-iso8583
C:\Users\milnishi\.node-red\node_modules\node-red-contrib-node-iso8583 -> C:\Program Files (x86)\nodejs\node_modules\node-red-contrib-node-iso8583 -> C:\vs02\nodered\node-contribu-node-iso8583

acoliveira Oliveira

unread,
Aug 16, 2017, 10:05:47 PM8/16/17
to Node-RED
solved,
Reply all
Reply to author
Forward
0 new messages