Skip to content

BAD 255 #16

Description

@MatheusNcam

Good afternoon!
Could anyone help me? I'm running the same code provided, just changing the port and ip, and in the end, all the arrays have a "BAD 255", for example:
TEST4: [ 'BAD 255', 'BAD 255' ]

Activity

  1. plcpeople commented on Jan 29, 2025

    @plcpeople
    Owner

    Are you able to post more information such as the console output of your program, information on PLC parts you're using, a Wireshark trace, etc? Bad 255 most often means no communication to the PLC - are you able to ping it?

  2. MatheusNcam commented on Jan 30, 2025

    @MatheusNcam
    Author

    I'll be able to send the information tomorrow, when I'll be in the office, but the model I want to get the information from is a Mitsubishi M70V Series PLC (CNC), I'm trying first via Ethernet cable and then via Modbus

  3. plcpeople commented on Jan 30, 2025

    @plcpeople
    Owner

    Are you sure this CNC PLC supports the same MC protocol that the Mitsubishi FX3U and other Mitsubishi PLCs support? I have zero experience with Mitsubishi CNC but I did a quick search and I'm not convinced it supports this protocol.

  4. MatheusNcam commented on Feb 3, 2025

    @MatheusNcam
    Author

    Good evening, sorry I didn't send it sooner, but it's below:
    I tried 3 ports (5002,683 and 111) and they got it "right"
    Code:

    var mc = require('mcprotocol');
    var conn = new mc;
    var doneReading = false;
    var doneWriting = false;
    
    var variables = { TEST1: 'D0,5', 	// 5 words starting at D0
    	  TEST2: 'M6990,28', 			// 28 bits at M6990
    	  TEST3: 'CN199,2',			// ILLEGAL as CN199 is 16-bit, CN200 is 32-bit, must request separately
    	  TEST4: 'R2000,2',			// 2 words at R2000
    	  TEST5: 'X034',				// Simple input
    	  TEST6: 'D6000.1,20',			// 20 bits starting at D6000.1
    	  TEST7: 'D6001.2',				// Single bit at D6001
    	  TEST8: 'S4,2',				// 2 bits at S4
    	  TEST9: 'RFLOAT5000,40'		// 40 floating point numbers at R5000	
    };										// See setTranslationCB below for more examples
    
    conn.initiateConnection({port: 683, host: '192.168.200.1', ascii: false}, connected); 
    
    function connected(err) {
    	if (typeof(err) !== "undefined") {
    		// We have an error.  Maybe the PLC is not reachable.  
    		console.log(err);
    		process.exit();
    	}
    	conn.setTranslationCB(function(tag) {return variables[tag];}); 	// This sets the "translation" to allow us to work with object names defined in our app not in the module
    	conn.addItems(['TEST1', 'TEST4']);	
    	conn.addItems('TEST6');
    //	conn.removeItems(['TEST2', 'TEST3']);  // We could do this.  
    //	conn.writeItems(['TEST5', 'TEST7'], [ true, true ], valuesWritten);  	// You can write an array of items as well.  
    	conn.writeItems('TEST4', [ 666, 777 ], valuesWritten);  				// You can write a single array item too.  
    	conn.readAllItems(valuesReady);	
    }
    
    function valuesReady(anythingBad, values) {
    	if (anythingBad) { console.log("SOMETHING WENT WRONG READING VALUES!!!!"); }
    	console.log(values);
    	doneReading = true;
    	if (doneWriting) { process.exit(); }
    }
    
    function valuesWritten(anythingBad) {
    	if (anythingBad) { console.log("SOMETHING WENT WRONG WRITING VALUES!!!!"); }
    	console.log("Done writing.");
    	doneWriting = true;
    	if (doneReading) { process.exit(); }
    }
    

    Console:

    [2933,564193300] Initiate Called - Connecting to PLC with address and parameters:
    [2933,569761100] { port: 683, host: '192.168.200.1', ascii: true }
    [2933,570457100] Connection cleanup is happening
    [2933,572312000 192.168.200.1] Attempting to connect to host...
    [2933,575224800 192.168.200.1] TCP Connection Established to 192.168.200.1 on port 683   
    [2933,576017800] Translation OK
    [2933,576962900 192.168.200.1] Adding D0,5
    Erro: tag D0,5 não encontrada
    C:\Users\usuario\Documents\códigos\mc-protocol\node_modules\mcprotocol\mcprotocol.js:2034
            splitString2 = addr.split(',');
                                ^
    
    TypeError: Cannot read properties of undefined (reading 'split')
        at stringToMCAddr (C:\Users\usuario\Documents\códigos\mc-protocol\node_modules\mcprotocol\mcprotocol.js:2034:22)
    PS C:\Users\usuario\Documents\códigos\mc-protocol> node process.js
    [2963,889529600] Initiate Called - Connecting to PLC with address and parameters:
    [2963,895302500] { port: 683, host: '192.168.200.1', ascii: false }
    [2963,896013900] Connection cleanup is happening
    [2963,897892600 192.168.200.1] Attempting to connect to host...
    [2963,901039400 192.168.200.1] TCP Connection Established to 192.168.200.1 on port 683
    [2963,901742900] Translation OK
    [2963,902289800 192.168.200.1] Preparing to WRITE TEST4
    [2963,911203700] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2963,923350900 192.168.200.1] We Caught a read/write error ECONNRESET - resetting connection
    [2963,925933700] ConnectionReset is happening
    [2964,21657500 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,22183100] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,138704700 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,139262200] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,239350000 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,240229700] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,354126400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,354604000] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,457158200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,457583200] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,572447100 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,572915900] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,673777200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,674644900] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,790940400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,791528100] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2964,906997400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2964,907447300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,8251900 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,9134300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,123607400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,124016400] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,225316100 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,227009400] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,336847300 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,337310400] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,427656200] ResetNOW is happening
    [2965,428662300] Clearing an earlier scheduled reset
    [2965,443860700 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,444510000] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,559211400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,559632700] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,678215300 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,678673800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,793340200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,793764800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2965,895201200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2965,895600800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,11808500 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,12250100] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,127899700 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,128312400] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,229915000 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,230318900] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,330236700 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,330632600] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,447654300 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,448217300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,563765300 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,564234800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,664753000 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,665146700] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,797149700 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,797817300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2966,898940000 192.168.200.1] Unable to read when not connected. Return bad values.
    [2966,899350500] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,14297900 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,14717900] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,115490100 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,115918300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,232775400 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,233253500] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,348804600 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,349315100] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,450985200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,451966300] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,566580200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,567011600] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,683306600 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,683715800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,784654800 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,785561100] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2967,889725600 192.168.200.1] Unable to read when not connected. Return bad values.
    [2967,890124600] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2968,1190200 192.168.200.1] Unable to read when not connected. Return bad values.
    [2968,1609700] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2968,102443300 192.168.200.1] Unable to read when not connected. Return bad values.
    [2968,103529500] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2968,218543000 192.168.200.1] Unable to read when not connected. Return bad values.
    [2968,218955500] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2968,319866800 192.168.200.1] Unable to read when not connected. Return bad values.
    [2968,321275800] Waiting to read for all R/W operations to complete.  Will re-trigger readAllItems in 100ms.
    [2968,419585700 192.168.200.1] WRITE TIMEOUT on sequence number 2
    [2968,421390600] Malformed Reply MC Packet - Less Than 2 Bytesundefined
    [2968,421928400] Stopping Processing Write Response Packet due to unrecoverable packet error
    [2968,422731200] R2000,2 write completed with quality BAD,BAD
    SOMETHING WENT WRONG WRITING VALUES!!!!
    Done writing.
    [2968,424106800 192.168.200.1] Unable to read when not connected. Return bad values.
    [2968,425097000 192.168.200.1] Adding TEST1,TEST4
    [2968,426714200 192.168.200.1] Adding TEST6
    [2968,429614300 192.168.200.1] Not Sending Read Packet because we are not connected - ISO CS is 0
    [2968,435500200 192.168.200.1] READ TIMEOUT on sequence number 3
    [2968,437214500 192.168.200.1] READ TIMEOUT on sequence number 4
    [2968,438061400 192.168.200.1] READ TIMEOUT on sequence number 5
    SOMETHING WENT WRONG READING VALUES!!!!
    {
      TEST1: [ 'BAD 255', 'BAD 255', 'BAD 255', 'BAD 255', 'BAD 255' ],
      TEST6: [
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255', 'BAD 255',
        'BAD 255', 'BAD 255'
      ],
      TEST4: [ 'BAD 255', 'BAD 255' ]
    }
    

    Wireshark:

    Image

  5. plcpeople commented on Feb 4, 2025

    @plcpeople
    Owner

    It doesn't seem to accept the write, so I think this CNC doesn't work with this protocol.

    Is there a place in GX Developer to set up the MC protocol connection similar to what is described in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions