Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am trying to send commands to the Vötsch oven based on the ASCII-II protocol but the oven does not seem to respond. The USBTOserial comm port is COM3

Am I sending it in the wrong way or am I not reading it right?
This is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Ports;



namespace Serial_Test
{
    class Program
    {  
        static SerialPort mySerialPort;
        static void Main(string[] args)
        {   
            mySerialPort = new SerialPort("COM3", 9600);

           


            try
            {
                mySerialPort.Open();
                mySerialPort.Write("$01I\r");

                while (true)
                {
                    try
                    {
                        if (mySerialPort.BytesToRead > 0) //if there is data in the buffer
                        {
                            byte b=(byte)mySerialPort.ReadByte(); //read a byte
                            Console.Write(b);
                            mySerialPort.Close();
                        }
                        //other code that can execute without being held up by read method.
                    }
                    catch (IOException ex)
                    {
                        Console.WriteLine(ex);
                        //error handling logic
                    }
                }

               

            }
            catch(IOException ex){

                Console.WriteLine(ex);
           }
        }
        
            }

        

        }


What I have tried:

The command Im supposed to send is $01I<cr> which gives the status of the oven but it does not respond. Any ideas would be appreciated
Posted
Updated 12-Nov-19 10:13am
v2

Your code looks correct to me.
I would try to send the same string with a serial terminal (like, for instance, putty[^]) in order to check if the oven actually communicates.
Then I would check the communication parameters (serial speed and flags) of the SerialPort object.
 
Share this answer
 
Comments
Patrice T 12-Nov-19 15:12pm    
+5
CPallini 12-Nov-19 15:44pm    
Thank you!
Start by checking you can communicate with the device directly, rather than adding unknown software to the equation.

Use Hyperterminal to connect directly, and manually send the data. Do you get a response? If so, then consider moving to software.
If you don;t, it could be a huge number of different things: baud rate, BPC, parity, start / stop bits, flow control lines, wrong data, - we cannot know, and we can't tell without access to both the PC and the device.

If you can't get it working after that, try looking at the manufacturers site - most will have sample code which should work "out of the box", or will have tech support which will know their equipment a whole lot better than we will!
 
Share this answer
 
In addition to 2 previous solutions.
Quote:
I am trying to send commands to the Vötsch oven based on the ASCII-II protocol but the oven does not seem to respond.

Debugging a serial link is a specialized task.
- First, you must make sure that the other device works as expected.
You need a terminal software like PuTTY[^], and use it to sent commands and see the answers. Once it work as expected, go to next step.

- Second, check your software. You need a second computer with a serial port and the terminal software. Link both computers and run your program, you will on terminal what is send, then send an answer to your program.

If you can't establish communication with device, you need to make sure that all settings match.
Another problem can be the cable of the wrong type. There is mainly 2 types, straight and null modem, which can't be exchanged.

Serial cable - Wikipedia[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900