ネットワーク経由でC#からPythonに整数を送信する必要があります。「ルール」が両方の言語で同じであり、それらのバイトサイズが同じである場合、バッファサイズである必要がありint(val)
、Pythonでのみ可能であることがわかりました... 私はできませんか?
どちらもサイズが 32 ビットなので、Python と C# で設定できるはずです
C#:
String str = ((int)(RobotCommands.standstill | RobotCommands.turncenter)).ToString();
Stream stream = client.GetStream();
ASCIIEncoding asen = new ASCIIEncoding();
byte[] ba = asen.GetBytes(str);
stream.Write(ba, 0, 32);
パイソン:
while True:
data = int( conn.recv(32) );
print "received data:", data
if( (data & 0x8) == 0x8 ):
print("STANDSTILL");
if( (data & 0x20) == 0x20 ):
print("MOVEBACKWARDS");