独木舟:-如何在CAPL脚本中使用位掩码

时间:2018-06-28 07:07:40

标签: capl canoe

我想屏蔽我的6位信号以传递20摄氏度的值

1 个答案:

答案 0 :(得分:0)

尝试

int firstvalue = 0xFF;
int secondValue = 0x55;
int result = 0;

result = firstvalue & 0xAA;
write("0xFF & 0xAA = %X", result);

result = secondValue & 0xAA;
write("0x55 & 0xAA %X", result);

result = secondValue & 0x01;
write("0x55 & 0x01 %X", result);

result = secondValue & 0;
write("0x55 & 0 %X", result);

result = firstvalue & 0x01;
write("0xFF & 0x01 %X", result);