I
I
Ivan2018-07-26 11:06:28
Node.js
Ivan, 2018-07-26 11:06:28

Why is the output through JS Socket and telnet/nc different?

There is a fairly simple task: devices (radio towers) are given that have only Telnet from the interaction interfaces, physically. There is a task to remove logs from them in real time, i.e. after entering certain commands, she starts to issue information about what is happening to her.
I dashed a script on JS, BUT for some reason the output "rides" and some left symbols appear.
For example, if you remove the log with telnet or nc, it will be something like this:

spoiler
[2018/07/26 14:13:24] [tCpeM] CPE[0x8090ede8] carry dns cfg
[2018/07/26 14:13:24] mem is not same, eid[8090ede8]
[2018/07/26 14:13:24] [tCpeM] CPE[0x8090ede8], proflie same=1 , ccb.getProfileInvalidFlag=0
[2018/07/26 14:13:24] [tCpeM] SetVersion[0x7ffe]
[2018/07/26 14:13:24] [tCpeM] post msg to ut ,len:104
[2018/07/26 14:13:24] [tCpeM] send register rsp to CPE[0x8090ede8], with profile.
[2018/07/26 14:13:24] [tCpeM] CPE profile update to CPE[0x8090ede8], transid:0xcf05
[2018/07/26 14:13:24] [tCpeM] Notify tVoice to enable or disable port.
[2018/07/26 14:13:24] [tCpeM] post tDM CPE[0x8090ede8]-config
[2018/07/26 14:13:24] [tCfg] CM_NuclearSendLimitData[UC] eid[8090ede8]
[2018/07/26 14:13:24] [tCpeM]SendValidFreqsParaToCpe cpe[0x8090ede8]
[2018/07/26 14:13:24] [tCpeM]SendCIParaToCpe cpe[0x8090ede8]
[2018/07/26 14:13:24] [tCpeM] CPE[0x8090ede8] register Status[0]. [SERVING]
[2018/07/26 14:13:24] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:13:24] [tCpeM] Receive CPE[0x8090ede8] Profile Update Response
[2018/07/26 14:13:24] [tCpeM] CPE[0x8090ede8] register SUCCESS.
[2018/07/26 14:13:24] [tCpeM] CPE_CpeGetNeighborListReq,UT[8090ede8] support V613
[2018/07/26 14:13:24] [tCpeM] eid[8090ede8] version = 3...
[2018/07/26 14:13:24] [tCpeM] CPE_CpeGetNeighborListReqNew,UT[8090ede8] support V613
[2018/07/26 14:13:24] [tCpeM] eid[8090ede8 ]CPE_CpeGetNeighborListReqNew add BtsType NeigBtsNum[0] DataLength = 6...
MCU_SW_version:02.06.00.cf
FPGA_SW_version:02.07.c5.66
MCU_SW_version:02.06.00.cf
FPGA_SW_version:02.07.c5.66
[2018/07/26 14:14:37] [tWRRU] RRU Freq Offset:[a30e],Antenna Mask:[ff] ,Temp:[39],Current:[3]
[2018/07/26 14:14:37] [tWRRU] rru_state_flag:[14]
MCU_SW_version:02.06.00.cf
FPGA_SW_version:02.07.c5.66
MCU_SW_version:02.06.00.cf
FPGA_SW_version:02.07.c5.66
[2018/07/26 14:15:45] [tCpeM] Rx CPE[0x8090edf9] profile update notify.
[2018/07/26 14:15:45] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:15:45] [tCpeM] CPE_CpeGetNeighborListReq,UT[8090edf9] support V613
[2018/07/26 14:15:45] [tCpeM] eid[8090edf9] version = 3...
[2018/07/26 14:15:45] [tCpeM] CPE_CpeGetNeighborListReqNew,UT[8090edf9] support V613
[2018/07/26 14:15:45] [tCpeM] eid[8090edf9 ]CPE_CpeGetNeighborListReqNew add BtsType NeigBtsNum[0] DataLength = 6...
MCU_SW_version:02.06.00.cf
FPGA_SW_version:02.07.c5.66
[2018/07/26 14:15:59] [tCpeM] Rx CPE[0x8090ee02] profile update notify.
[2018/07/26 14:15:59] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:16:10] [tCpeM] Rx CPE[0x80039b06] profile update notify.
[2018/07/26 14:16:10] [tCpeM] ->CPEServingCpeProfileUpdateNotifyTrans, receive new cpe profile update notify from L2, then send utTable1 to L2
[2018/07/26 14:16:10] [tCpeM] Post ut ability req msg to L2 success
[2018/07/26 14:16:10] [tCpeM] ->CPE fsm reclaim()

And here is what the JS outputs:
spoiler
[
2018/07/26 14:45:57] [tCpeM] Rx CPE[0x80909bf1] Register_Req, [Serving state],transID:0x27
[2018/07/26 14:45:57] [tCpeM]CPE[0x80909BF1] judge wcpe or rcpe.
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] profile is valid.
[2018/07/26 14:45:57] [tCpeM] Old cpe register req don't carry utTable1
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] RegisterReq UT NonAdjacent is [0]
[2018/07/26 14:45:57] [tCpeM] Send CPE[0x80909BF1] BWInfo_Req to HLR.
[2018/07/26 14:45:57] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:45:57] [tCpeM] Receive CPE[0x80909bf1] BWInfo_Rsp, Admin_status: 0. [SERVING state]
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] register Status[0]. [SERVING],BW:8,8
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] carry dns cfg
[2018/07/26 14:45:57] mem is not same, eid[80909bf1]
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1], proflie same=1 , ccb.getProfileInvalidFlag=0
[2018/07/26 14:45:57] [tCpeM] SetVersion[0x7ffe]
[2018/07/26 14:45:57] [tCpeM] post msg to ut ,len:104
[2018/07/26 14:45:57] [tCpeM] send register rsp to CPE[0x80909bf1], with profile.
[2018/07/26 14:45:57] [tCpeM] CPE profile update to CPE[0x80909bf1], transid:0xcf5a
[2018/07/26 14:45:57] [tCpeM] Notify tVoice to enable or disable port.
[2018/07/26 14:45:57] [tCpeM] post tDM CPE[0x80909bf1]-config
[2018/07/26 14:45:57] [tCfg] CM_NuclearSendLimitData[UC] eid[80909bf1]
[2018/07/26 14:45:57] [tCpeM]SendValidFreqsParaToCpe cpe[0x80909bf1]
[2018/07/26 14:45
:57] [tCpeM]SendCIParaToCpe cpe[0x80909bf1]
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] register Status[0]. [SERVING]
[2018/07/26 14:45:57] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:45:57] [tCpeM] Receive CPE[0x80909bf1] Profile Update Response
[2018/07/26 14:45:57] [tCpeM] CPE[0x80909bf1] register SUCCESS.

[
2018/07/26 14:46:04] [tCpeM] Rx CPE[0x8090edf6] profile update notify.
[2018/07/26 14:46:04] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:46:04] [tCpeM] CPE_CpeGetNeighborListReq,UT[8090edf6] support V613
[2018/07/26 14:46:04] [tCpeM] eid[8090edf6] version = 3...
[2018/07/26 14:46:04] [tCpeM] CPE_CpeGetNeighborListReqNew,UT[8090edf6] support V613
[2018/07/26 14:46:04] [tCpeM] eid[8090edf6 ]CPE_CpeGetNeighborListReqNew add BtsType NeigBtsNum[0] DataLength = 6...
[2018/07/26 14:46:04] [tCpeM] Rx CPE[0x8090edf6] Register_Req, [Serving state],transID:0x5
[2018/07/26 14:46:04] [tCpeM]CPE[0x8090EDF6] judge wcpe or rcpe.
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] profile is valid.
[2018/07/26 14:46:04] [tCpeM] Old cpe register req don't carry utTable1
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] RegisterReq UT NonAdjacent is [0]
[2018/07/26 14:46:04] [tCpeM] Send CPE[0x8090EDF6] BWInfo_Req to HLR.
[2018/07/26 14:46:04] [tCpeM] ->CPE fsm reclaim()
[2018/07/26 14:46:04] [tCpeM] Receive CPE[0x8090edf6] BWInfo_Rsp, Admin_status: 0. [SERVING state]
[2
018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] register Status[0]. [SERVING],BW:8,8
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] carry dns cfg
[2018/07/26 14:46:04] mem is not same, eid[8090edf6]
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6], proflie same=1 , ccb.getProfileInvalidFlag=0
[2018/07/26 14:46:04] [tCpeM] SetVersion[0x7ffe]
[2018/07/26 14:46:04] [tCpeM] post msg to ut ,len:104
[2018/07/26 14:46:04] [tCpeM] send register rsp to CPE[0x8090edf6], with profile.
[2018/07/26 14:46:04] [tCpeM] CPE profile update to CPE[0x8090edf6], transid:0xcf5c
[2018/07/26 14:46:04] [tCpeM] Notify tVoice to enable or disable port.
[2018/07/26 14:46:04] [tCpeM] post tDM CPE[0x8090edf6]-config
[2018/07/26 14:46:04] [tCfg] CM_NuclearSendLimitData[UC] eid[8090edf6]
[2018/07/26 14:46:04] [tCpeM]SendValidFreqsParaToCpe cpe[0x8090edf6]
[2018/07/26 14:46:04] [tCpeM]SendCIParaToCpe cpe[0x8090edf6]
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] register Status[0]. [SERVING]
[2018/07/26 14:46:04] [tCpeM] ->CPE fsm reclaim()

[2018/07/26 14:46:04] [tCpeM] Receive CPE[0x8090edf6] Profile Update Response
[2018/07/26 14:46:04] [tCpeM] CPE[0x8090edf6] register SUCCESS.

[
2018/07/26 14:46:04] [tCpeM] CPE_CpeGetNeighborListReq,UT[8090edf6] support V613
[2018/07/26 14:46:04] [tCpeM] eid[8090edf6] version = 3...
[2018/07/26 14:46:04] [tCpeM] CPE_CpeGetNeighborListReqNew,UT[8090edf6] support V613
[2018/07/26 14:46:04] [tCpeM] eid[8090edf6 ]CPE_CpeGetNeighborListReqNew add BtsType NeigBtsNum[0] DataLength = 6...

MCU_SW_version:
02.06.00.cf
FPGA_SW_version:02.07.c5.66

It can be seen that there were some left line feeds. But, it would seem that for clarity, I took an example from nc and netcat from npm. From here I get the feeling that I somehow handle buffer incorrectly.

The first listing is made from nc . The second is based on the netcat library . Those. in fact it should be the same, but no!
The code:
const NetcatClient = require("netcat/client");
const client = new NetcatClient();

client
    .addr("192.168.10.10")
    .port(23)
    .connect();

client.on("connect", () => {
    console.log("Connected!");
});
client.on("data", data => {
    console.log(data.toString());
    data = data.toString().split(/\r\n/gm);
    data.forEach(value => {
        switch (value.trim()) {
            case "VxWorks login:":
                client.send("bts\n");
                break;
            case "Password:":
                client.send("12345678\n");
                break;
            case "->":
                // Основное приглашение
                client.send("reDirect 0\n");
                break;
            default:
                // console.log(data);
                break;
        }
    });
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question