March 29, 2024, 02:02:23 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


CHR$(0) Problem

Started by ids065, November 10, 2022, 02:59:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ids065

Hi,
I use IWBSENDBYTE and IWBSENDPORT to transfer data over a serial port. But I now have a device which needs binary data and that isn't a problem I simply create a string such as mydata$=CHR$(1)+CHR$(5) etc. and it works perfectly but I have to send a byte with all 8 bits set to zero but it is impossible to put CHR$(0) into the string, I suspect it is the end of string marker. Even using IWSENDBYTE will not send a CHR$(0) byte. I tried various things without success. Does anyone have an idea how I can get this byte with all 8 bits set to zero sent to the com port.


Brian

I don't have or use the serial port software, so have no experience of it, but maybe you could just send a NULL?

Brian

ids065

Hi Brian,

thanks for the answer though unfortunately as far as I can see IWB doesn't recognise null as any sort of keyword, unlike some languages.

Ian

Brian

That's funny, because my current program has a few references to NULL:

hIcon=NULL
IF pDB<>NULL THEN dbDisconnect(pDB)
IF dbName[0]=NULL

IDE Version: 3.05
Compiler Version: 2.095

Brian

Bruce Peaslee

My ASCII chart shows zero (0) for NULL.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ckoehn

The command to use is IWSendByte( port, char).

The help example uses:

int port = 5
char oc = 63  'could be 0 instead of 63

if IWSendByte(port,char)
  print "success"
end if

This should work.  I use to use this library all the time and I too needed to send chr$(0).

Later,
Clint

ids065

Hi, thanks for the replies yes I agree null is 0 and I have tried to make a variable equal to it but again it can't be put into any form of string because it is the end of string marker.

I thought I had tried using the IWSendByte and it worked fine for all values other than 0 but I will try it again.