Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Configuring port rs232

 
webmaster forum
psm  Offline
Activity
0%
 
New Poster
Posts: 6
Topics: 3
November 11, 2009, 12:40:20 PM

Good evening,
please can you help me with this code? I want to change it, because I must read some data from reader, which will be access to pc by rs232.
Thank you.

Code:

#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
DCB dcb;
HANDLE hCom;
BOOL fSuccess;
char *pcCommPort = "COM2";

hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);

if (hCom == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf ("CreateFile failed with error %d.\n", GetLastError());
return (1);
}

// Build on the current configuration, and skip setting the size
// of the input and output buffers with SetupComm.

fSuccess = GetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("GetCommState failed with error %d.\n", GetLastError());
return (2);
}

// Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit.

dcb.BaudRate = CBR_57600; // set the baud rate
dcb.ByteSize = 8; // data size, xmit, and rcv
dcb.Parity = NOPARITY; // no parity bit
dcb.StopBits = ONESTOPBIT; // one stop bit

fSuccess = SetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("SetCommState failed with error %d.\n", GetLastError());
return (3);
}

printf ("Serial port %s successfully reconfigured.\n", pcCommPort);
return (0);
}

« Last Edit: August 25, 2011, 07:52:46 PM by Admin »
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
January 05, 2010, 04:27:44 PM

Change what exactly? It is difficult to know what you want to do if you don't provide further details

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
webmaster forum
Activity
0%
 
New Poster
Posts: 10
Topics: 5
August 21, 2010, 10:49:45 PM

The Cisco manual describes this in detail.

Rather than try to restate the manual herein, which is way beyond the ability of this forum, I suggest you consult the manual.

Remember the switch does not have a DHCP server so you must manually set your pc on the subnet the switch is on and then change the IP address.

Often this is done easiest in CLI so if you do not know command line language, you will need to beef up your skill here as well.  Again check the manuals.
« Last Edit: August 25, 2011, 07:53:09 PM by Admin »
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
August 22, 2010, 01:45:53 AM

The Cisco manual describes this in detail.

Rather than try to restate the manual herein, which is way beyond the ability of this forum, I suggest you consult the manual.

Remember the switch does not have a DHCP server so you must manually set your pc on the subnet the switch is on and then change the IP address.

Often this is done easiest in CLI so if you do not know command line language, you will need to beef up your skill here as well.  Again check the manuals.

The op wanted to read values from the rs232 in their c code and use them for processing. This has nothing to do with Cisco, DHCP nore IP addresses.

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
webmaster forum
cipl  Offline
Activity
0%
 
New Coder
Posts: 25
Topics: 0
April 29, 2011, 01:24:53 AM

RS232 is a serial communication port.  You can read and write data serially with the help of RS232.  I have use RS232 with the assembly language so I am not able to give the proper solution for this one.  

Network Management Service
 
webmaster forum
mak14317  Offline
Activity
0%
 
Skilled Coder
Real name: Janne
Location: california
Gender: Male
Age: 26
Posts: 108
Topics: 1
WWW
May 03, 2011, 11:29:49 PM

no idea actully what u want....from RS 232  cable........

herbal vaporizer
Happy vappy vaporizer
Eclipse Vape
Ivape
 
webmaster forum
john14317  Offline
Activity
0%
 
Skilled Coder
Posts: 149
Topics: 0
July 05, 2011, 05:23:14 AM

There is a short and sweet introduction here: http://www.robbayer.com/serial.php Just click on the Windows link.

payday loans
instant online cash advance
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 05, 2012, 06:56:47 PM