SerialOut command not available on ZX-24?
SerialOut command not available on ZX-24?
I'm trying to port a program made originally in PBasic over to ZBasic, and it looks like the ZX-24 does not support the SerialOut function? Are there alternatives to this command?
Re: SerialOut command not available on ZX-24?
Yes, neither SerialOut() nor SerialIn() are supported on VM-mode devices like the ZX-24, ZX-24a, ZX-24p and ZX-24r. They are supported on native mode devices like the ZX-24n and ZX-24s. It should be noted that the functionality of SerialOut() is similar to but not identical to that of SEROUT in PBasic.lwcyb wrote:I'm trying to port a program made originally in PBasic over to ZBasic, and it looks like the ZX-24 does not support the SerialOut function?
Which 24-pin ZX device are you actually using?
Depending on what it is you're trying to do, using one of the software serial channels (Com3-Com6) may work perfectly.lwcyb wrote:Are there alternatives to this command?
If you haven't seen it, you may find the PBasic Conversion Guide useful.
- Don Kinzer
SerialOut command not available on ZX-24?
> ... what command to use to send the hexadecimal characters?
That depends upon the OLED device you're using. What is it?
Tom
That depends upon the OLED device you're using. What is it?
Tom
Tom
To send any data out the serial channel, all you need to do is to add it to the output queue that you associated with the serial channel when you opened it. The data will be sent in the order that you add it to the queue, e.g.lwcyb wrote:I believe I've defined and opened a com channel successfully, my only question now is what command to use to send the hexadecimal characters?
Code: Select all
PutQueueByte(oq, Asc("A"))
PutQueueByte(oq, &H41)
PutQueueByte(oq, 65)
- Don Kinzer
I am using a 4D uOLED screen.
FF and D7 are used to clear the screen, and 00, 0C, 00, 00 is used to disable the screen saver that appears. The 2.7 second delay is placed there because this is recommended by 4D (the oled screen manufacturer). I've confirmed I'm using the correct # pin (pin 8) for transmitting, but I'm not seeing the screen clear itself. In PBasic serial commands the hexadecimal codes are separated by commas, is there a character I'm missing here that I should be using instead of an empty space (" ")?
Thank you both for your assistance.
Code: Select all
Dim str as String = &HFF & " " & &HD7
Dim outQueue(1 to 40) as Byte
Call OpenQueue(outQueue, SizeOf(outQueue))
Call ComChannels(1, 9600)
Call DefineCom(4, 0, 8, &H08)
Call OpenCom(4, 9600, 0, outQueue)
Call Delay(2.7)
Call PutQueueStr(outQueue, str)
Debug.print str
str = &H00 & " " & &H0C & " " & &H00 & " " & &H00
Call PutQueueStr(outQueue, str)
Debug.print str
Thank you both for your assistance.
One problem is that you're using ComChannels() to tell the compiler that there will be just one SW serial port (which will be Com3) but then you use Com4 which is, of course, not valid.lwcyb wrote: I've confirmed I'm using the correct # pin (pin 8) for transmitting, but I'm not seeing the screen clear itself.
You only need to use ComChannels() if you plan to use a SW serial channels beyond Com3. The additional channels are Com4, Com5 and Com6 but those are only valid if the first parameter to ComChannels() is large enough, e.g. for Com4 it must be at least 2, for Com5 it must be at least 3, and for Com6 it must be 4. The second parameter to ComChannels() is used to indicate the maximum baud rate that any open channel will use.
Note that the function StatusCom() gives information about a serial channel including if it is valid or not. If you were to insert the line below after the ComChannels() call you'll discover that Com4 isn't valid at that point.
Code: Select all
Debug.Print "Com4 is "; IIF(CBool(StatusCom(4) And &H01), "", "not "); "valid"
In PBasic, the commas are required to separate the digits of the character codes. In the code you've shown, the ampersand serves the save function. I doubt that the space characters are needed.lwcyb wrote:In PBasic serial commands the hexadecimal codes are separated by commas, is there a character I'm missing here that I should be using instead of an empty space (" ")?
It would be easier to help if you could post a link to the documentation for the device.
- Don Kinzer
http://www.4dsystems.com.au/downloads/S ... REV1.3.pdf
Stupid mistake on my end, I switched the RX and TX pins around. Still doesn't function 100% but now it is actually responding. The default scrolling screensaver is affected by the code - it is not disabled and does not clear but it does reset itself. I'll have to play around a little bit more with this.
Thanks again for the clarifications.
Stupid mistake on my end, I switched the RX and TX pins around. Still doesn't function 100% but now it is actually responding. The default scrolling screensaver is affected by the code - it is not disabled and does not clear but it does reset itself. I'll have to play around a little bit more with this.
Thanks again for the clarifications.
There is still the issue with using an invalid comm channel. I presume that you fixed that, too?lwcyb wrote:Stupid mistake on my end, I switched the RX and TX pins around.
My hunch that the space characters weren't needed is correct. Try this:lwcyb wrote:[...] and does not clear but it does reset itself.
Code: Select all
Const oledChan as Byte = 3
Sub Main()
Dim outQueue(1 to 40) as Byte
Call OpenQueue(outQueue, SizeOf(outQueue))
Call DefineCom(oledChan, 0, 8, &H08)
Call OpenCom(oledChan, 9600, 0, outQueue)
Call Delay(2.7)
Call PutQueueStr(outQueue, Chr(&Hff) & Chr(&Hd7))
Call Delay(1.0)
Call PutQueueStr(outQueue, Chr(&H00) & Chr(&H0c) & Chr(&H00) & Chr(&H00))
End Sub
Also, if you were using a native mode device, like the ZX-24s, you could use the Arduino or C libraries provided by 4D Systems. I haven't looked at the functionality available in those libraries but it is likely that it would save you a lot of time and frustration.
- Don Kinzer