Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

serialinblock for binary bytes receiving. limited to the 127 value


PhilO Aug 2, 2019 08:50 AM

Hi,

I need to reveive on a CR1000x some values from a postionning controler.

It send me binary data and I have to assembling 4 bytes to build a complete 32 bits number.

when the controler send values until 127 it is OK but starting with 128 it doesn't work.

I suppose It is due to the ascci fonction I use witch is limited to ascci 0-127 and not ANSI code 0-255...

here is a part of my code.

If someone can give me a hand , tanks a lot!

Public Treuil_RSIN_car As String *100

Public Treuil_Position_actuelle,Treuil_Position_demande As Long
Public byte1,byte2,byte3,byte4 As Long

Function Treuil_DMD_position_actuelle ' lecture de la variable partagee dans l'adresse 0x3005.02
SerialFlush(Com_treuil)
SerialOutBlock(Com_treuil, CHR(&h53)+ CHR(&h07) + CHR(&h01) + CHR(&h01) + CHR(&h05)+ CHR(&h30)+ CHR(&h02),7)
SerialOutBlock(Com_treuil, CHR(&h35)+ CHR(&h45),2)' h35 CRC desactive dans le controleur ,h45= EOF
Delay(1,200,msec)

SerialInBlock(Com_treuil,Treuil_RSIN_car,20)
byte1= ASCII(Treuil_RSIN_car(1,1,8))
byte2= ASCII(Treuil_RSIN_car(1,1,9))
byte3= ASCII(Treuil_RSIN_car(1,1,10))
byte4= ASCII(Treuil_RSIN_car(1,1,11))

Treuil_Position_actuelle = (byte4<<24) + (byte3<<16) + (byte2<<8) + byte1
End Function


JDavis Aug 2, 2019 05:30 PM

I think the limit is not actually the ASCII function, but the format chosen in SerialIn. If you are using format 0 in SerialOpen, try format 3.


PhilO Aug 6, 2019 09:01 AM

Tanks a lot, that is working well now with format3 in SerialOpen !

Log in or register to post/reply in the forum.