C# :: Receive String Plus Image From Serial Port?

Sep 3, 2014

i want to read the string plus image from serialport.

sample output:
DENOMI Ver SERIAL NUMBER
100 V <<<<IMAGE>>>>
100 N <<<<IMAGE>>>>

but when im trying to receive the data and using serialPort.ReadExisting();

this is the output:

DENOMI Ver SERIAL NUMBER
100 V *!???????q??q??y??y?y?q?????????xxxxppppp????y?py?`q??q??q? q???????????????8?p8?@8??8???????? ?????8??8?p8?p?p??p??p?????????q?q?p8 p88?p8?????????????8?p8?p8?p8?p8??8??x??x8?8?8??p?p??p??p0?py?p????????~8?q??q??q??p8?????p??????????????????????????????p8?x?x<?x<?x<??<?????

View 1 Replies


ADVERTISEMENT

C# :: How To Send And Receive Data From Serial Port

Aug 13, 2014

private void button1_Click(object sender, EventArgs e) {
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;

[Code]...

In my project i have a serialport control and a button, there is no error but i want to know how actually this works, i want to send and recieve the data from the serial port don't know how to do it..

View 9 Replies View Related

C# :: Receive Data From Serial Com Port In One Line And Convert To Int

Mar 8, 2014

i have problem i make code that take data from serial com port for weighting machine it is ok working but it recieve data in more lines.I try to make it receive data in one line In code below i need to take weight fro weight bridge machine automatically by timer in visual studio 2005.it works but receive weight values in more lines. I need to receive weight in one line and automatically updated then convert t to integer

void Application_Idle(object sender, EventArgs e)
{
label3.Text = serialPort1.IsOpen ? "[Open]" : "[Closed]";
}

[Code].....

View 3 Replies View Related

C/C++ :: How To Completely Send A String Through Serial Port

May 9, 2013

I am doing a messaging application using Visual C++ window form application.

Sometimes I can't receive a whole message from the sender. If i type short sentence like "123456", it can be shown properly. But, if i type a quite long sentence like "123456789123456789", it can't shown a correct message, can't show exactly the whole message.

here is my code:

//transmission:
String^ message;
String^ message1;
String^ name = this->serialPort1->PortName;

[Code].....

View 1 Replies View Related

C++ :: Inserting Hex Value And Sending It At Serial Port

Dec 17, 2013

I am trying to convert decimal value 1 to 32 to hex value and insert it at 4th pos of char array and send it as hex value at the serial port .

My issue is it is converting to decimal to hex value but when it sends, it treat the converted hex value as char and sends it equivalent hex value.

For example

if decimal =1 then its hex = 1.
so , writebuffer[3] =1

But when we send whole writebuffer through send function, it treat this 1 as char and sends its hex value as 31. how to send its hex value.

unsigned int i=0;
char hex[3];
unsigned char hexunsigned[3];
unsigned int dec;
do {
unsigned char writebuffer[8] ={0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

[Code] ....

The send function is

void serial::send(unsigned char data[], DWORD noOfByte) {
DWORD dwBytesWrite;
WriteFile(serialHandle, data, noOfByte, &dwBytesWrite, NULL);
}

View 2 Replies View Related

C++ :: Read Serial Port Using Libserial?

Apr 14, 2014

I am using libserial library to communicate through the serial port in c++. the linux cpu is communicating with a modem through the serial port. basically this is what i want to do

Code:
//I want:
cpu to write command_1 to modem
Wait for the answer from modem
read serial port
check if command successful (i.e modem sends OK if successful and ERROR if there is an error)

If there is an error, resend command_1

if successful then Write command_2 to modem Wait for answer read again serial port check if command is succesful (modem again sends OK if successful and ERROR if there is an error) basically, this is the code...

Code:
serial_port <<command_1 <<'
'; //send 1st command
sleep(2); //delay a while

[Code].....

View 6 Replies View Related

C :: Voltage Range - Write The Value On Serial Port

Mar 6, 2015

I have a Voltage Range from -10V up to +10V, which I transform to a voltage Range 0V to 5V, with the schematic i've attached, so I can use the A/D converter of my ATMEGA32 processor.

Now I'd like to write the value of the Input Voltage (which moves in the Range of -10V to + 10V) on the serial port, but i don't know how i should calculate this factor. At the moment, I can only write the value of the A/D Converter Input on the serial, but this is only 0V to 5V...

View 2 Replies View Related

C :: How To Read And Write A File Using Serial Port

Dec 29, 2013

Explain me a working code to read and write a file using serial communication.and i need to store that file.I know normal file handling in C, but how it is through serial port i am not getting.

View 1 Replies View Related

C++ :: How To Send UNICODE Characters To Serial Port

Jul 17, 2013

I am trying to write data in Russian language to the serial (RS-232) port. My display device is already set to that character code page.

But output on the device is not exactly what I require.

My code snippet is like this below

CString pBuffer = L"английский"; //Russian Language
LPBYTE pByte = new BYTE[pBuffer.GetLength() + 1];
memcpy(pByte, (VOID*)LPCTSTR(pBuffer), pBuffer.GetLength());
long nBuffer=pBuffer.GetLength()+1;
DWORD dwWritten=0;
WriteFile(pHandle , pByte, nBuffer ,&dwWritten , NULL);

pHandle is a valid handle.

View 4 Replies View Related

C# :: Read Barcode Scanner Value From Serial Port

Jun 2, 2010

How can i read barcode scanner value from serial port?

View 5 Replies View Related

Visual C++ :: How To Read And Write On Serial Port With MFC

Feb 17, 2013

I want to read and write value on serail port to Microcontroller with MFC. The MFC have no serial port tool like in VB Professionnal edition. I try to find MFC connect serial port example but I not found. If you have good example for read and write on serial port with MFC

View 2 Replies View Related

Visual C++ :: Data Stuck When Debugging With Serial Port

May 10, 2014

I am making a MFC application with VC++2012 with receiving data from Serial Port and the data is stored in a Listbox, then after processing (convert into numbers) and get these data to draw a sine wave on the chart. (I intend to make a virtual oscilloscope).

Everything works ok at the beginning, but after receiving about 300 items or above (in the Listbox) the value seem stucking (or lagging) and work very slowly.

I receive data by the SerialPort_DataReceived() method, and process of converting and drawing chart also in this method, I think this makes the system overload!!

View 1 Replies View Related

Visual C++ :: Sending Packet Of Type Byte To Serial Port

Feb 26, 2013

I need to send a packet of type byte:

0x00, 0x01, 0x02, 0x11, 0x00, 0x00

to a device via the serial port and then I receive and store data coming from device like this:

0x01, 0x01, 0x01 , 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00.

Writing lines of code through which:

1) I create the array
2) the sending the array to serial port
3) I'll see what I'm sending
4) I get the data

I'm using Visual Studio 2010 and C + + or VC++ language.

View 14 Replies View Related

C++ :: Libserial Library To Interact With Modem - Read Serial Port

Jun 27, 2014

I am using libserial library to interact with a modem using c++. The C++ code sends an AT command:

Code:
my_serial_stream << "AT+CSQ" << '
' ;

The modem responds with a response, either ERROR or OK, The c++ code to read the response:

Code:
while( serial_port.rdbuf()->in_avail() > 0 )
{
char next_byte;
serial_port.get(next_byte);
std::cerr << std::hex << (int)next_byte << " ";
}
std::cerr << std::endl;

I would like to handle the response such that if the response is OK, the modem sends another command and if the response is ERROR, the modem resends the first command.

View 1 Replies View Related

C++ :: Access Serial Port - This Declaration Has No Storage Class Or Type Specifier

Feb 26, 2013

I am writing a code using Visual C++ to access serial port.

Code:
HANDLE hSerial= CreateFile(L"COM1", GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
DCB dcb = {0};
dcb.DCBlength=sizeof(dcbSerialParams);
dcb.BaudRate=CBR_1200;
dcb.ByteSize=8;
dcb.StopBits=ONESTOPBIT;
dcb.Parity=NOPARITY;

I am getting error in all last five lines in above code at dcb. and error is give below:-

Error: this declaration has no storage class or type specifier

View 2 Replies View Related

C Sharp :: How To Pick Date / Time When Serial Port Starts Reading And Also When Stops

Aug 18, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.Ports;

[Code] ....

How to pick date / time when serial port starts reading , and also when reading stops ?

View 2 Replies View Related

C# :: One Thread Trying To Pass Data To Another Thread Using Serial Port

Jul 30, 2014

I have a class which I wrote and one of its object is "SerialPort" .NET class. In my MainWindow I created instance of my class called "SerialPortComm", then I send through some functions of mine, commands to the Serial Port, and I receive answers through "DataReceived" event.

But when I trying to use Dispatcher.BeginInvoke to write my data I have received (successfully), nothing shows on the RichTextBox which I'm trying to write to.

What can caused that, and How I can make it works?

SerialPortComm.cs

public partial class SerialPortComm : UserControl {
public SerialPort mySerialPort = new SerialPort();
public void Open_Port(string comNumber, int baudRate) {
mySerialPort.PortName = comNumber;
mySerialPort.BaudRate = baudRate;

[Code] ....

View 7 Replies View Related

C# :: Base 64 String To Image And Display In Gridview

Apr 7, 2015

Im trying to convert a base 64 string to an image and store in a gridview control (windows 8)

instead of an image im seeing text in the control
Windows.UI.Xaml.MediaImaging.Bitmap

convert base 64 string to bitmap

public async Task<BitmapImage> Base64ToImage(string base64)
{
var bitmap = new BitmapImage();
var buffer = Convert.FromBase64String(base64);
using (var stream = new Windows.Storage.Streams.InMemoryRandomAccessStream()) {

[Code] ....

View 2 Replies View Related

C# :: Compare The Image Of A Button To Another Image In Visual Studio

Jul 3, 2014

Im trying to compare the image of a button to another image in Visual Studio like so...

//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");

[Code]...

btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))

I do have a feeling ive done something wrong here (Yes im a noob /> )

Variable active, is the same image as the buttons default (Well should be)

View 1 Replies View Related

C :: Can't Seem To Receive UDP Packets

Jun 2, 2013

I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never logs that it got the data.

I just keep getting a log showing that my recvfrom timed out. I'm pretty sure I'm setting everything up correctly.

Code:
int create_listen_socket() {
struct sockaddr_in si_me;
int sock_fd;
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;
void * tmpAddrPtr=NULL;
struct timeval tv;

[Code] ....

View 1 Replies View Related

C# :: Socket TCP Send / Receive

Jun 28, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace test {

[Code] ....

I don't know if this is a bug in Winsock or the .NET Framework but i need to fix this or workaround. Recently I was working on a networking class and this error is breaking everything.

If you add Thread.Sleep(1) after Send() call then "TCP Bug detected" doesnt get executed but its not a reliable fix.

View 7 Replies View Related

C++ :: Winsock - Receive / Send Sequences

Oct 25, 2013

I'm trying to understand winsock with c++. Let's assume I have a 2 working applications, one is the client and one the server:

Client: I can enter a command, for example chat or filetransfer, it will then switch into this specific mode where I can enter commands like uploading a file, send a message etc.

Client
Code: ....
while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf);
if (strcmp(buf, "CHAT") == 0){
// start chat mode

[Code] .....

I'm in a recv/send loop and I'm using streams...so basically all the data is being sent/received there. Now, if I want to upload a file, I send a FILETRANSFER String to the server. Then I will probably need another loop that receives file requests from the client. The server will need more details about the file, like the path, name, size...

Now, my question is, what's the best practise for something like that? I'm having problems understand how I can send 3 different values from the server to the client and how he will receive them in the right order store them in variables. And also, after sending something to the server, in some cases, the client will have to wait for the server to answer.

Is there a good example of a similar application?

View 3 Replies View Related

C++ :: HTTP Response Receive Using Socket

May 18, 2014

I make a simple c++ http post request using socket and it is working fine. But how to get only the message of the response. Here is my receive code:

char buffer[1028];
recv(socket, buffer, sizeof(buffer), 0);
printf("%s", buffer);

Then here is the response that the http send back.

HTTP/1.1 200 OK
Data: Mon, 19 May 2014 12:46:36 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27
X-Powered-By: PHP/5.4.27
Coneten-Length: 28
Content-Type: text/html

All done! Do some stuff now. So what I want to try is get 3 things in this response and put them to string vector but how to do this. What I need is to parse the response and the 200 OK, 28 and All done! Do some stuff now. then put them to string vector.

expected result

response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now

View 2 Replies View Related

C/C++ :: Receive 20 Numbers Or Less And Find Average?

Apr 27, 2015

I made a program that is suppose to receive 20 numbers or less and find the average, then show all numbers entered but my average does not show. It shows as 0 and a line pops up after every number returned. I am stuck and dont know how to fix the logical errors.

#include <iostream>
#include <cmath>
using namespace std;
int main() {
float num[20];
int amount_num;

[Code] ....

View 3 Replies View Related

Visual C++ :: How To Receive POST Data

Sep 24, 2014

I need to write an interface program in C++ to receive occasional data being sent to me from a different company from across the internet. The company says they will send the data using POST. They have given me a document that lists their data specific parameters and their meaning.

How do I receive this data in my C++ program?

View 14 Replies View Related

C :: Reading File In But Receive Segmentation Fault

Sep 28, 2013

question regarding some segmentation fault I receive while running the code I have been working on. I am working on a card program and this is my input:

Code:
TS QC 8S 8D QH 2D 3H KH 9H 2H TH KS KC
9D JH 7H JD 2S QS TD 2C 4H 5H AD 4D 5D
6D 4S 9S 5S 7S JS 8H 3D 8C 3S 4C 6S 9C
AS 7C AH 6H KD JC 7D AC 5C TC QD 6C 3C
3C 6C QD TC 5C AC 7D JC KD 6H AH 7C AS
9C 6S 4C 3S 8C 3D 8H JS 7S 5S 9S 4S 6D
5D 4D AD 5H 4H 2C TD QS 2S JD 7H JH 9D
KC KS TH 2H 9H KH 3H 2D QH 8D 8S QC TS

What I am trying to do is read in 52 cards name into array, set up the game and play it, when the game is done, I read the next 52 cards and play it again.

However, I encounter segmentation fault while running the program. Here is my code

Code:
#include <stdio.h>#include <stdlib.h>
#include "header.h"
extern FILE *open_file();

[Code].....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved