Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serial and USB ports
#1
Hi,
I'm a recent (re)convert to QB, having used it many years ago, so I'm learning all over again.

Can anyone point me towards any information about using the serial ports (actually the USB ports) under Linux (Mint) please?. I had a browse through this forum, looking at various things which might help, but not had much success, and my very old recollections don't stir any memories.
Reply
#2
Hi Keith,

I'm not a Linux user, but we do have a fair amount here who are. Anyway, I just wanted to welcome you to the forum and since it may take a while for the right user to find this post and respond, I want to encourage you to post a bit more on what access to using the usb ports will do in your program. That might help someone to better help you. If you already have some code, posting it would help even more.

Pete
Reply
#3
Hi, Pete - thanks for the message.

I'm working on developing an Eprom Programmer to read and program the older series 27XXX type Eproms - basically so I can support some old computers (ORIC, SINCLAIR ZX81 and similar).
It consists of a Controller, running on a PC (in my case under Linux Mint - sorry, I'm not a lover of Windows in any form), with a serial connection (USB) to the Programmer itself. 
The programmer is an Arduino Nano, used to present and accept data to the Eprom, set up the required programming voltage, and generate programming pulses. This is programmed in Arduino CPP, and is working fine.
The Controller (currently) is partly written in Gambas3, (for those who don't know, this is similar to Visual Basic). It is used to pass control and program data to the Arduino Programmer.
I chose to write the Controller in something 'Basic' - like, because maybe eventually  I will make the programmer/system public, and  since the Programmer only requires control bytes and data passed by a 'standard' serial port, it could be controlled from virtually any computer. For this reason, I wanted to keep the Controller software simple (I.e avoid compiling, etc), then if anyone wants to write their own controller (in any language) they are free to do so.
I mentioned I started with Gambas3, but as I have worked on it, I have found the handling of the serial port under Gambas3 is not as straightforward as it could be, and despite subscribing to various forums, I cannot find some of the information I need. Currently, it is working 'up to a point', but I'm not happy.
I decided to push it to one side for the moment, and try another Basic, and since I had read about QB64-PE, and had used QB many (many, many......) years ago, decided it would be interesting to revisit it, and see how it has developed. I have seen somewhere there is a serial library available for it, and it also offers the use of InForm to generate graphic UI's, so it seemed a possibility - which is where I am now, and is the reason for my question about Serial Port handling. I only need to be able to read/write single bytes, and ideally I need some program indication that data is available at the port for reading. Gambas3 has this, but is event-driven. The port will accept data into the receive buffer, but it is the program responsibility to read this data, and so far, I have found no way of getting an indication (in Gambas) that data is waiting. As a consequence of this, sometimes data gets overwritten - bummer!. I am sure that eventually I will find a way round this, but in the interests of getting a working Programmer/Controller, which is simple to understand, I want to investigate alternatives.
I want to program 'old' devices, but the same principle could be used for more modern devices, or for serially programmed devices - so I need to know about QB64 serial port handling. 

Regards, Keith
Reply
#4
I will be watching this to see if theres anything I missed.

I used qb64pe on my desktop, with a serial USB adapter and had to open it like this:
open "/dev/ttyUSB0" for binary as #1.
Also, I needed to open the port in a com program first, or use 'stty' command line in a 'shell' command.
but after that it seemed to work fine.
Reply
#5
Thanks for your input, Parkland.

What you is describe is similar (partly) to the method in Gambas3 - except I am opening it for read or write. Somewhere in my searches I came across something about opening the port using a com program first - think it was 'CuteCom' under Windows. If this is the case, its bit cumbersome - I rather hope I can find something that can be set up in QB64PE..
Anything I can find I will post here, so it can maybe used by someone else.

I guess you are working under Windows - ttyUSB?, and as yet I don't know if there is any difference in Linux - partly my reason for asking if anyone knew of any documentation. I'll try and give your suggestion a try under Linux, and see what happens. I assume that if you don't open the port with a separate com program, then it remains closed to QB64PE?

I'm beginning to think that I might have to write my own Serial Port Library. Since most computers nowadays offer USB ports, it may not be a big problem. There will be no need to handle the Serial handshake lines for USB use, The only setting will be Baud Rate, number of bits, and number of stopbits, so it might be worth a go.

Regards - Keith
Reply




Users browsing this thread: 1 Guest(s)