@@ -1582,25 +1582,31 @@ Job.prototype.if_robot_status_error_default = function(){
15821582 let sim_actual = Robot . get_simulate_actual ( rob . simulate )
15831583 if ( ( sim_actual === false ) || ( sim_actual === "both" ) ) {
15841584 try { let path = "Dexter." + rob . name + ":/srv/samba/share/errors.log"
1585- read_file_async ( path , undefined , function ( err , content ) {
1586- if ( err ) { warning ( "Could not find: " + path ) }
1587- else {
1588- if ( ( typeof ( content ) != "string" ) ||
1589- ( content . length == 0 ) ) {
1590- content == "<i>errors.log is empty</i>"
1591- }
1592- else {
1593- content = replace_substrings ( content , "\n" , "<br/>" )
1594- content = "Content of " + path + "<br/><code>" + content + "</code>"
1595- setTimeout ( function ( ) { write_file_async ( path , "" ) } ,
1596- 400 ) //give the read_file job a chance to finish properly
1585+ read_file_async ( path , undefined , function ( err , content ) {
1586+ if ( err ) { warning ( "Could not find: " + path + " with error: " + err . message ) }
1587+ else {
1588+ let msg = ""
1589+ if ( ( typeof ( content ) != "string" ) ||
1590+ ( content . length == 0 ) ) {
1591+ msg = "<i>errors.log is empty</i>"
1592+ }
1593+ else {
1594+ let content_arr = content . split ( "\n" )
1595+ let last_line = content_arr . pop ( )
1596+ if ( last_line . trim ( ) . length === 0 ) { //if the last line is empty, this gets 2nd to last line.
1597+ last_line = content_arr . pop ( )
15971598 }
1598- out ( content )
1599+ last_line = last_line . replaceAll ( "," , ",<br/>" )
1600+ msg += "<details><summary>Last error in " + path + "</summary><code>" + last_line + "</code></details>"
1601+ //setTimeout(function(){DDEFile.write_file_async(path, "")},
1602+ // 400) //give the read_file job a chance to finish properly
15991603 }
1600- } )
1601- }
1604+ out ( msg )
1605+ }
1606+ } )
1607+ }
16021608 catch ( err ) { warning ( "In Job.prototype.if_robot_status_error_default, could not get the errors.log file<br/>" +
1603- " for " + "Dexter." + rob . name ) }
1609+ " for " + "Dexter." + rob . name + " with error: " + err . message ) }
16041610 }
16051611 }
16061612 return Control . error ( msg )
@@ -1635,22 +1641,52 @@ Job.prototype.if_dexter_connect_error_default = function(robot_name){
16351641Job . prototype . rs_to_error_message = function ( robot_status ) {
16361642 let error_code = robot_status [ Dexter . ERROR_CODE ]
16371643 let oplet_error_code = error_code & 0xFF //lower 8 bits
1638- let msg = "error_code: " + error_code
16391644 let oplet = robot_status [ Dexter . INSTRUCTION_TYPE ]
1645+ let msg = "oplet: " + oplet + " oplet_error_code: " + oplet_error_code
16401646 if ( error_code > 0 ) {
1641- if ( ( oplet == "r" ) || ( oplet == "w" ) ) {
1642- let linux_msg = linux_error_message ( oplet_error_code )
1643- msg += "Error on oplet 'r' (read_file) with Linux error of: " + linux_msg
1647+ if ( ( oplet === "r" ) || ( oplet === "w" ) ) {
1648+ let linux_msg = globalThis . linux_error_message ( oplet_error_code )
1649+ msg += " Linux error: " + linux_msg
1650+ }
1651+ else if ( ( oplet_error_code === 8 ) && ( ( oplet === "a" ) || ( oplet === "P" ) || ( oplet === "j" ) ) ) {
1652+ msg += " Goal position outside joint boundries."
1653+ }
1654+ else if ( oplet === "j" ) {
1655+ msg += " j_move error: "
1656+ if ( oplet_error_code === 4 ) {
1657+ msg += " Ruckig compute error. Check JointHardwareMax??? configuration."
1658+ }
1659+ else if ( oplet_error_code === 5 ) {
1660+ msg += " Ruckig cannot meet specified duration."
1661+ }
1662+ else if ( oplet_error_code === 6 ) {
1663+ msg += " Replay error. Under-run or over-speed."
1664+ }
1665+ else if ( oplet_error_code === 7 ) {
1666+ msg += " j_move system in an error state."
1667+ }
1668+ msg += " Clear using 'j' oplet without args."
16441669 }
16451670 else {
1646- if ( oplet_error_code == 1 ) { msg += " oplet:" + oplet + " is unknown to Dexter. Please upgrade Dexter firmware and gateware.<br/>" }
1647- else if ( oplet_error_code == 2 ) { msg += " on oplet:" + oplet + " communication error.<br/>" }
1648- else { msg += " on oplet:" + oplet + " Unknown error.<br/>" }
1671+ if ( oplet_error_code == 0 ) { } //don't add an extra message
1672+ else if ( oplet_error_code == 1 ) { msg += " oplet is unknown to Dexter. Please upgrade Dexter firmware and gateware.<br/>" }
1673+ else if ( oplet_error_code == 2 ) { msg += " communication error. No semicolon at end of instruction.<br/>" }
1674+ else if ( oplet_error_code == 3 ) { msg += " invalid parameter.<br/>" }
1675+ else { msg += " Unknown error.<br/>" }
16491676 }
1677+ //error flags
16501678 if ( error_code & ( 1 << 10 ) ) { msg += " Firmware - Gateware Mismatch. Update system. Fatal error.<br/>" }
1651- if ( error_code & ( 1 << 27 ) ) { msg += " SPAN Servo, Joint 7. r 0 errors.log <br/>" }
1652- if ( error_code & ( 1 << 28 ) ) { msg += " ROLL Servo, Joint 6. r 0 errors.log <br/>" }
1653- if ( error_code & ( 1 << 30 ) ) { msg += " Joint Monitor. r 0 errors.log <br/>" }
1679+ if ( error_code & ( 1 << 24 ) ) { msg += " P-Stop error code.<br/>" }
1680+ if ( error_code & ( 1 << 25 ) ) { msg += " Encoder error.<br/>" }
1681+ if ( error_code & ( 1 << 26 ) ) { msg += " Kinematics error.<br/>" }
1682+ if ( error_code & ( 1 << 27 ) ) { msg += " SPAN Servo, Joint 7.<br/>" }
1683+ if ( error_code & ( 1 << 28 ) ) { msg += " ROLL Servo, Joint 6.<br/>" }
1684+ if ( error_code & ( 1 << 30 ) ) { msg += " Joint Monitor.<br/>" }
1685+ for ( let i = 11 ; i < 24 ; i ++ ) {
1686+ if ( error_code & ( 1 << i ) ) {
1687+ msg += " Unknown error flag on bit: " + i + ".<br/>"
1688+ }
1689+ }
16541690 }
16551691 return msg
16561692}
0 commit comments