Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1866 connectés 

  FORUM HardWare.fr
  Programmation
  Divers

  Langage de prog. simple type BASIC pour RS232, vos idées SVP

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Langage de prog. simple type BASIC pour RS232, vos idées SVP

n°1233407
briconique
Posté le 28-10-2005 à 13:23:40  profilanswer
 

bonjour,
 
je me sers de cette petite interface http://www.util-pocket.com/electronique/upi.htm sur Psion et Amiga qui ont un langage de programmation simple et efficace et sachant gérer le port RS 232.
je voudrais l'utiliser sur PC maintenant. Mais je n'ai rien d'autre que QBASIC.
QBASIC est pleinement fonctionnel avec cette interface mais il est très "dépouillé" et limité vis à vis des possibilités (graphiques notamment) de windows XP.
auriez-vous SVP un langage de programmation simple, "moderne", si possible freeware, et capable de gérer les ports COM RS232 ?
 
d'avance merci.
 
cordialement, LAF

mood
Publicité
Posté le 28-10-2005 à 13:23:40  profilanswer
 

n°1261412
lbasic
Posté le 08-12-2005 à 02:25:13  profilanswer
 

Just BASIC possède des commandes pour ouvrir le port serie. il est gratuit.
voici ci dessous un aperçu du fichier d'aide:
 

Citation :

OPEN "COMn:baud,parity,data stop{,options}" for random as #handle
 
Description:
 
The OPEN "COMn:" statement opens a serial communications port for reading and writing.  This feature uses Microsoft Windows' own built-in communications API, so if you have a multiport communications card and a WIndows driver to support that card, you should be able to use any port on the card.
 
The simplest form for this command is:
 
    OPEN "COMn:baud,parity,data,stop" for random as #handle
 
Allowable choices for baud are:
 
    75 110 150 300 600 1200 2400 1800 2400 4800 9600 19200 38400 57600 115200
 
Allowable choices are parity are:
 
    N No parity
    E Even parity
    O Odd parity
    S Space parity
    M Mark parity
 
Allowable choices for data are:
 
    5 bits long
    6 bits long
    7 bits long
    8 bits long
 
Allowable choices for stop are:
 
    1 stop bit
    2 stop bits
 
Additional optional parameters can be included after the baud, parity, data and stop information:
 
    CSn  Set CTS timeout in milliseconds (default 1000 milliseconds)
 
    DSn  Set DSR timeout in milliseconds (default 1000 milliseconds)
    PE  Enable parity checking
    RS  Disable detection of RTS (request to send)
 
Other defaults:
 
    DTR detection is disabled
    XON/XOFF is disabled
    binary mode is the default
 
To set the in and out communications buffers (each port has its own), set the variable Com (notice the uppercase C) to the desired size before opening the port.  Changing the variable after opening a port does not affect the size of the buffers for that port while it is open.
 
    'set the size of the communications buffers  
    '(in and out) to 16K each
    Com = 16384
 
Usage Notes:
 
To open com port 2 at 9600 baud, 8 data bits, 1 stop bit, and no parity, use this line of code:
 
    open "com2:9600,n,8,1" for random as #commHandle
 
It is recommended that you set certain handshaking switches so that your program doesn't just freeze when waiting for data to come in or trying to send data.  To do this, we add ds0, cs0, and rs switches as below.  You needs may differ, but these work well for most applications.  Notice we use a different communications speed in this example.
 
 
    open "com2:19200,n,8,1,ds0,cs0,rs" for random as #commHandle
 
Remember that when a modem dials and connects to another modem, it negotiates a cpnnectopm speed.  In the case of 14400 speed modems, you need to specify 19200 as the connection speed and let the modems work it out between themselves during the connect.  This is because 14400 is not a baud rate supported by Windows (and you'll find that QBASIC doesn't directly support 14400 baud either).
 
 
Once the port is open, sending data is accomplished by printing to the port (ATZ resets modems that understand the Hayes command set):
 
    print #commHandle, "ATZ"
 
To read from the port you should first check to see if there is anything to read.  This is accomplished in this fashion:
 
    numBytes = lof(#commHandle)
 
Then read the data using the input$() function.
 
    dataRead$ = input$(#commHandle, numBytes)
 
Putting the lof( ) and input$( ) functions together on one line, it looks like this:
 
    dataRead$ = input$(#commHandle, lof(#commHandle))
 
When you're all done, close the port:
 
    close #commHandle
 
 
Just BASIC has the ability to disable DSR checking by specifying a zero or non value using the DS switch:  
 
    open "com1:9600,n,8,1,ds0" for random as #com
 
  or
 
    open "com1:9600,n,8,1,ds" for random as #com
 
Use the txcount(#handle) function to get a count of bytes in a serial communications transmit queue.
 
    count = txcount(#com)


 
@++


Message édité par lbasic le 08-12-2005 à 02:26:56

---------------
Liberty BASIC France : http://www.lbasic.fr

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Divers

  Langage de prog. simple type BASIC pour RS232, vos idées SVP

 

Sujets relatifs
indentation du code dans visual basicInput Type=text
time_t et localtime : assignment from incompatible pointer typecompilateur basic
langage logoprog POSIX sous windows
Combien de jours pour se former en visual basic??Démarrage prog
prog c (gcc) sous os x ??Input type
Plus de sujets relatifs à : Langage de prog. simple type BASIC pour RS232, vos idées SVP


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR