drunsinn / pyLSV2

A pure Python3 implementation of the LSV2 protocol
MIT License
64 stars 24 forks source link

I'm looking for the description or reason of each LSV2 protocol error numbers. Is there a document #30

Closed sazima closed 1 year ago

sazima commented 2 years ago

https://github.com/drunsinn/pyLSV2/blob/220f350ca732cfd4ce9ab49c8997e2daf909d8c4/pyLSV2/const.py#L195

class LSV2Err(IntEnum):
    """Enum for LSV2 protocol error numbers"""

    T_ER_BAD_FORMAT = 20
    T_ER_UNEXPECTED_TELE = 21
    T_ER_UNKNOWN_TELE = 22
    T_ER_NO_PRIV = 23
    T_ER_WRONG_PARA = 24
    T_ER_BREAK = 25
    T_ER_BAD_KEY = 30
    T_ER_BAD_FNAME = 31
    T_ER_NO_FILE = 32
    T_ER_OPEN_FILE = 33
    T_ER_FILE_EXISTS = 34
    T_ER_BAD_FILE = 35
    T_ER_NO_DELETE = 36
    T_ER_NO_NEW_FILE = 37
    T_ER_NO_CHANGE_ATT = 38
    T_ER_BAD_EMULATEKEY = 39
    T_ER_NO_MP = 40
    T_ER_NO_WIN = 41
    T_ER_WIN_NOT_AKTIV = 42
    T_ER_ANZ = 43
    T_ER_FONT_NOT_DEFINED = 44
    T_ER_FILE_ACCESS = 45
    T_ER_WRONG_DNC_STATUS = 46
    T_ER_CHANGE_PATH = 47
    T_ER_NO_RENAME = 48
    T_ER_NO_LOGIN = 49
    T_ER_BAD_PARAMETER = 50
    T_ER_BAD_NUMBER_FORMAT = 51
    T_ER_BAD_MEMADR = 52
    T_ER_NO_FREE_SPACE = 53
    T_ER_DEL_DIR = 54
    T_ER_NO_DIR = 55
    T_ER_OPERATING_MODE = 56
    T_ER_NO_NEXT_ERROR = 57
    T_ER_ACCESS_TIMEOUT = 58
    T_ER_NO_WRITE_ACCESS = 59
    T_ER_STIB = 60
    T_ER_REF_NECESSARY = 61
    T_ER_PLC_BUF_FULL = 62
    T_ER_NOT_FOUND = 63
    T_ER_WRONG_FILE = 64
    T_ER_NO_MATCH = 65
    T_ER_TOO_MANY_TPTS = 66
    T_ER_NOT_ACTIVATED = 67
    T_ER_DSP_CHANNEL = 70
    T_ER_DSP_PARA = 71
    T_ER_OUT_OF_RANGE = 72
    T_ER_INVALID_AXIS = 73
    T_ER_STREAMING_ACTIVE = 74
    T_ER_NO_STREAMING_ACTIVE = 75
    T_ER_TO_MANY_OPEN_TCP = 80
    T_ER_NO_FREE_HANDLE = 81
    T_ER_PLCMEMREMA_CLEAR = 82
    T_ER_OSZI_CHSEL = 83
    LSV2_BUSY = 90
    LSV2_X_BUSY = 91
    LSV2_NOCONNECT = 92
    LSV2_BAD_BACKUP_FILE = 93
    LSV2_RESTORE_NOT_FOUND = 94
    LSV2_DLL_NOT_INSTALLED = 95
    LSV2_BAD_CONVERT_DLL = 96
    LSV2_BAD_BACKUP_LIST = 97
    LSV2_UNKNOWN_ERROR = 99
    T_BD_NO_NEW_FILE = 100
    T_BD_NO_FREE_SPACE = 101
    T_BD_FILE_NOT_ALLOWED = 102
    T_BD_BAD_FORMAT = 103
    T_BD_BAD_BLOCK = 104
    T_BD_END_PGM = 105
    T_BD_ANZ = 106
    T_BD_WIN_NOT_DEFINED = 107
    T_BD_WIN_CHANGED = 108
    T_BD_DNC_WAIT = 110
    T_BD_CANCELLED = 111
    T_BD_OSZI_OVERRUN = 112
    T_BD_FD = 200
    T_USER_ERROR = 255
drunsinn commented 2 years ago

The error numbers are matched via the translation function in def get_error_text(error_type, error_code, language=None, locale_path=None): """Parse error type and error code and return the error message. to a more descriptive text message found in the translation po/mo files. If you supply create a localization file based on these messages in your target language I can include them in the package! Take a look at gettext, that is the technology used for the translation.

sazima commented 2 years ago

When I call read_plc_memory, there is an error in the log. Do you know how to solve this problem, Thank you. The model of the cnc is iTNC530E.

res = c.read_plc_memory(764, MemoryType.WORD)

WARNING:root:T_ER or T_BD received, an error occurred during the execution of the last command: LSV2_ERROR_T_ER_NO_LOGIN
ERROR:root:an error occurred during login for login Login.PLCDEBUG
WARNING:root:T_ER or T_BD received, an error occurred during the execution of the last command: LSV2_ERROR_T_ER_NO_PRIV
ERROR:root:failed to read string from address 828
drunsinn commented 2 years ago

First, it seems that the you haven't installed the library with pip so the installation is missing the translation files. That is the reason you get these nondescript error messages like LSV2ERROR... . If you install the package via pip there are translation files included which I mentioned earlier. If you don't care about installing with pip just copy the *.mo files from the python package into the location you store the library. The package can be downloaded from the Python package index

Regarding the error messages: LSV2_ERROR_T_ER_NO_LOGIN translates to "login not possible" and LSV2_ERROR_T_ER_NO_PRIV translates to "no privilege for execution" It seems like the you need a password for the login PLCDEBUG. The function read_plc_memory() tries to login without a password which works on a programming station.

Maybe your machine is configured differently which is why it dosen't work. In that case you would have to run login(login=Login.PLCDEBUG, password="secret") before reading the plc memory. Just replace the password with the correct phrase. To geht the password you might have to ask the manufacturer of your machine or try the usual passwords....

sazima commented 2 years ago

First, it seems that the you haven't installed the library with pip so the installation is missing the translation files. That is the reason you get these nondescript error messages like LSV2ERROR... . If you install the package via pip there are translation files included which I mentioned earlier. If you don't care about installing with pip just copy the *.mo files from the python package into the location you store the library. The package can be downloaded from the Python package index

Regarding the error messages: LSV2_ERROR_T_ER_NO_LOGIN translates to "login not possible" and LSV2_ERROR_T_ER_NO_PRIV translates to "no privilege for execution" It seems like the you need a password for the login PLCDEBUG. The function read_plc_memory() tries to login without a password which works on a programming station.

Maybe your machine is configured differently which is why it dosen't work. In that case you would have to run login(login=Login.PLCDEBUG, password="secret") before reading the plc memory. Just replace the password with the correct phrase. To geht the password you might have to ask the manufacturer of your machine or try the usual passwords....

I gave feedback to my customers and hoped they could ask for the password. If there is follow-up, I will update this issue. Thanks for your help!!!