Editing Talk:SC Communication
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== The easy peasy lemon squeasy way (UART) (CXR/CXRF/SW) == | == The easy peasy lemon squeasy way (UART) (CXR/CXRF/SW) == | ||
<syntaxhighlight lang="Python"> | |||
from binascii import unhexlify as uhx | from binascii import unhexlify as uhx | ||
from Crypto.Cipher import AES # pycryptodome | from Crypto.Cipher import AES # pycryptodome | ||
Line 73: | Line 71: | ||
if(length >= 0x40): | if(length >= 0x40): | ||
if(self.command('SETCMDLONG FF FF')[0] != 0): | if(self.command('SETCMDLONG FF FF')[0] != 0): | ||
return ( | return ('Setcmdlong', []) | ||
checksum = sum(bytearray(com, 'ascii')) % 0x100 | checksum = sum(bytearray(com, 'ascii')) % 0x100 | ||
self.send('{}:{:02X}\r\n'.format(com, checksum)) | self.send('{}:{:02X}\r\n'.format(com, checksum)) | ||
Line 87: | Line 85: | ||
answer = answer.split(':') | answer = answer.split(':') | ||
if(len(answer) != 3): | if(len(answer) != 3): | ||
return ( | return ('Answer length', []) | ||
checksum = sum(bytearray(answer[2], 'ascii')) % 0x100 | checksum = sum(bytearray(answer[2], 'ascii')) % 0x100 | ||
if(answer[0] != 'R' and answer[0] != 'E'): | if(answer[0] != 'R' and answer[0] != 'E'): | ||
return ( | return ('Magic', []) | ||
if(answer[1] != '{:02X}'.format(checksum)): | if(answer[1] != '{:02X}'.format(checksum)): | ||
return ( | return ('Checksum', []) | ||
data = answer[2].split(' ') | data = answer[2].split(' ') | ||
if(answer[0] == 'R' and len(data) < 2 or answer[0] == 'E' and len(data) != 2): | if(answer[0] == 'R' and len(data) < 2 or answer[0] == 'E' and len(data) != 2): | ||
return ( | return ('Data length', []) | ||
if(data[0] != 'OK' or len(data) < 2): | if(data[0] != 'OK' or len(data) < 2): | ||
return (int(data[1], 16), []) | return (int(data[1], 16), []) | ||
Line 105: | Line 103: | ||
answer[i] = answer[i].replace('\n', '').rsplit(':', 1) | answer[i] = answer[i].replace('\n', '').rsplit(':', 1) | ||
if(len(answer[i]) != 2): | if(len(answer[i]) != 2): | ||
return ( | return ('Answer length', []) | ||
checksum = sum(bytearray(answer[i][0], 'ascii')) % 0x100 | checksum = sum(bytearray(answer[i][0], 'ascii')) % 0x100 | ||
if(answer[i][1] != '{:02X}'.format(checksum)): | if(answer[i][1] != '{:02X}'.format(checksum)): | ||
return ( | return ('Checksum', []) | ||
answer[i][0] += '\n' | answer[i][0] += '\n' | ||
ret = answer[-1][0].replace('\n', '').split(' ') | ret = answer[-1][0].replace('\n', '').split(' ') | ||
Line 190: | Line 188: | ||
print('{:08X}'.format(ret[0]) + '\n' + ''.join(ret[1])) | print('{:08X}'.format(ret[0]) + '\n' + ''.join(ret[1])) | ||
else: | else: | ||
print(ret[1][0]) | print(ret[1][0].decode('ascii')) | ||
if __name__ == '__main__': | if __name__ == '__main__': | ||
main(len(sys.argv), sys.argv) | main(len(sys.argv), sys.argv) | ||
</syntaxhighlight> | |||
</syntaxhighlight> | |||
* Credits to M4j0r for the RE of this important info | * Credits to M4j0r for the RE of this important info | ||
== IDs == | == IDs == | ||
Line 368: | Line 245: | ||
</pre> | </pre> | ||
* Although this service is not used on Slim and some Phat consoles anymore, it is working | * Although this service is not used on Slim and some Phat consoles anymore, it is working. | ||
* It seems it have the same restrictions as NVS service. | * It seems it have the same restrictions as NVS service. | ||
Line 387: | Line 264: | ||
</pre> | </pre> | ||
* Although this service is not used on Slim and some Phat consoles anymore, it is working | * Although this service is not used on Slim and some Phat consoles anymore, it is working. | ||
* It seems it have the same restrictions as NVS service. | * It seems it have the same restrictions as NVS service. | ||
Line 818: | Line 695: | ||
See : | See : | ||
* https:// | * https://imgur.com/a/Iwv4d | ||
* https:// | * https://imgur.com/a/48gsT | ||
* database : https://www.sendspace.com/file/6awfi9 | * database : https://www.sendspace.com/file/6awfi9 | ||
For proof | For proof |