Sign in to follow this  
Followers 0
benyamin200

problem with serial port

6 posts in this topic

hello

i wrote a program for getting data from serial port but when i want sent a string to Hyper terminal not working this program

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBoxEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include<CommMG.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("Humidity", 410, 139, 191, 126)
$Combo1 = GUICtrlCreateCombo("PORT", 24, 16, 153, 25)
$Label1 = GUICtrlCreateLabel("", 156, 60, 116, 28)
GUICtrlSetBkColor(-1, 0xFF8040)
$Button1 = GUICtrlCreateButton("Search", 200, 16, 65, 25, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Humidity", 80, 64, 44, 17)
$Input1 = GUICtrlCreateInput("Input1", 280, 64, 41, 21)
$Label3 = GUICtrlCreateLabel("", 156, 96, 116, 28)
GUICtrlSetBkColor(-1, 0xFF0000)
$Input2 = GUICtrlCreateInput("Input2", 280, 96, 41, 21)
$Label4 = GUICtrlCreateLabel("temperature", 80, 96, 60, 17)
$Radio1 = GUICtrlCreateRadio("Radio1", 328, 64, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 328, 96, 113, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$a=0
$status=1
$data=0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
        $com=StringSplit(_CommListPorts(),"|",1)
        $a=$a+1
        $port=StringRight($com[$a],1)
            _GUICtrlComboBox_AddString($Combo1,"COM:"&$port)
         EndSwitch
    
    $port=_GUICtrlComboBox_GetEditText($Combo1)
    $port=StringRight($port,1)
    $statusport=_CommSetport($port,'',9600,8,'none',1,1)

     if $statusport==1 And $status==1 Then
         _CommSendString("GE")
         $status=0
         $data=1
      EndIf
      if $data==1 Then
         dim $ddata 
         $ddata=_CommGetString()
         ConsoleWrite($ddata)
         EndIf
WEnd

Share this post


Link to post
Share on other sites



"not working" <---We're supposed to know what you mean by this? How about a little more explanation on what isn't working, what errors you're receiving, etc.? Help us help you.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

thanks and excuse me for my bad english

so  for example i send "77777"to serial port

but i receive just "7" from serial port

Share this post


Link to post
Share on other sites

i used VSPE software"Virtual serial port emulator" and i make a virtual serial port and i send to hyper terminal

Share this post


Link to post
Share on other sites

There is a program called dlwedgeutility -> http://www.datalogic.com/tools/download.aspx?iddwnfile=3287&path=%2fupload%2fmarketlit%2fsoftware%2fsu%2fSU-WEU.zip&name=SU-WEU You can at least find out the correct communication settings for your device with this. Works with Windows XP and 7.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

no problem in serial port i just don't know how can i useed this "_CommGetString()"in COMMG.au3 library

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0