|
SuffixValue = _deviceSettingsKeys.GetValue("ReceiveSuffix", "");
if (SuffixValue != null)
_RCVData = _SetSerialPort.ReadTo(SuffixValue);
else
_RCVData = _SetSerialPort.ReadLine();
Can you fix this, how i should do this.
|
|
|
|
|
You should do some string replace...
* find escape character (\)
* check if next character has special meaning after escape
* replace the pair with the real one...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I can do that things whatever you are telling, but here problem is when take harcoded value "\r\n" instead of SuffixValue then its working fine, but when i pass use variable then its not working....can you post any way to do it.
Thanks Kornfeld Eliyahu Peter
|
|
|
|
|
I'm going to bet that your code isn't really converting it into \\r\\n. I rather suspect that you have put a breakpoint in your code (well done for that), and you are inspecting the value in the debugger - this is why it appears to be incorrect. The debugger shows escape characters as double slash, rather than single slash - but the underlying value is still a single slash.
|
|
|
|
|
No, when i pass \r\n from registry
if (SuffixValue != null)
_RCVData = _SetSerialPort.ReadTo(SuffixValue);
else
_RCVData = _SetSerialPort.ReadLine();
From the registry i am taking suffix value "\r\n". When i do hard coding then its working fine:
When i take using variables then its not reading. When i use variable then getting System.TimeoutException: The operation has timed out.
if (SuffixValue != null)
_RCVData = _SetSerialPort.ReadTo("\r\n");
else
_RCVData = _SetSerialPort.ReadLine();
modified 18-Feb-14 6:12am.
|
|
|
|
|
Yes correct exactly i am doing the same what you mention in your comment
|
|
|
|
|
Ok Ok...i am agree with you, what you are telling is correct. But can you run this and check why its not showing the TRUE results:::
class Program
{
static void Main(string[] args)
{
string check = "324214234\r\n";
RegistryKey regKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\MyRegKey\\Settings");
regKey.SetValue("ReceiveSplChar", @"\r\n");
string value = regKey.GetValue("ReceiveSplChar").ToString();
if (check.Contains(value))
Console.WriteLine("TRUE");
}
}
|
|
|
|
|
The reason is to do with what you are writing to the registry. By putting @"\r\n", you have told the application to write a slash followed by r followed by a slash followed by an n. These are four separate characters. Change that line to:
regKey.SetValue("ReceiveSplChar", "\r\n"); It will now work.
|
|
|
|
|
It may useful to you. [*]
|
|
|
|
|
Hi,
Datetime can't be change to other format [dd/MM/yyyy] to [MM/dd/yyyy],[yyyy/MM/dd],... like that
<pre lang="text">
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JqueryDate.aspx.cs" Inherits="DtPicker.JqueryDate" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<title></title>
<script src="Scripts/jquery-1.7.1.min.js"></script>
<script src="Scripts/jquery.jdpicker.js"></script>
<link href="Scripts/jdpicker.css" rel="stylesheet" />
</head>
<script type="text/javascript">
// $(document).ready(function () {
// });
$("#Country").change(function () {
var ddl_value = $('#Country').val();
//$("#test1").val(ddl_value);
$("#dt").val(ddl_value);
location.reload(); // datepicker select to reload
})
$('#dt').jdPicker({
date_format: $("#dt").val()
//date_format:"MM dd YYYY"
})
</script>
<body>
<form id="form1" runat="server">
<select id="Country">
<option value="dd/mm/YYYY">Ind dd/mm/YYYY</option>
<option value="FF dd YYYY">Russia FF dd YYYY</option>
<option value="dd MM YYYY">Qatar dd MM YYYY</option>
<option value="MM dd YYYY">Japan MM dd YYYY</option>
<option value="dd FF YYYY">Singapore dd FF YYYY</option>
<option value="YYYY/mm/dd">Canada YYYY/mm/dd</option>
</select>
<div class="jdpicker_w">
<p>Date:<input type="text" id="dt" size="30" class="jdpicker"/></p>
</div>
</form>
</body>
</html>
</pre>
//=================================================================================================
// JS file
//=================================================================================================
http://jdpicker.paulds.fr/?p=demo
I am using this datetime picker.
how to solve this issue?
Thanks,
Karthikeyan,Bangalore
|
|
|
|
|
Please use the "code" button to markup your code as such. it will wrap the code in <pre> tags making it clearer to view.
This is how I set the datetimeformat in JQueries datetimepicker:
$('#dts_start').datetimepicker(
{
showWeek:true,
showSecond: true,
dateFormat: "dd/mm/yy",
timeFormat: "hh:mm:ss",
yearRange: "-500:+10",
changeMonth: true,
changeYear: true
}
);
it is actually an overriden datetimepicker. see here : http://trentrichardson.com/examples/timepicker/[^]
You do know that on the JQuery homepage there is a complete API with samples ?
Hope this helps.
|
|
|
|
|
Please do not cross post between forums - you already have this question in JS forum, it's place is there...for sure not c#!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Not only have you posted this in the wrong forum, you've already posted it twice in the JavaScript forum, and twice in Quick Answers.
You have already been given several answers, which you seem to have ignored.
You've been a member of this site for nearly seven years. You've had plenty of time to realise that reposting the same question, or posting the same question in different forums, is frowned upon. You only need to annoy five people enough to have them report your account for you to get kicked off the site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I have a POS software with a txtBarCode textbox. I want when the user scan the bar code and after the textbox was idle for 3 seconds to run find_product() class?
How can I do this please?
also if you have a better idea to perform the same?
Thanks
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
Hi Jassim,
You can make use of DispatcherTimer to act like an stopwatch with trigger, to do some action after some elapsed time.
Code:
var timer = new DispatcherTimer
{
Interval = new TimeSpan(0, 0, 3)
};
timer.Tick += timer_Tick;
void timer_Tick(object sender, object e)
{
}
Now you can Start/Stop this timer from the place as per requirement as in below snippet.(say after scan/read complete start the timer)
timer.Start();
So after 3 seconds, your timer_Tick method will invoke.
Thanks,
Raj
|
|
|
|
|
Hi,
When i am trying to read long string like more that 5 characters then characters are splitting.
EX: Q2345456
output - Q2345
public void RecievedData(object sender, SerialDataReceivedEventArgs e)
{
try
{
_RCVData = _SetSerialPort.ReadExisting();
if (SerialDataEvent != null)
{
SerialDataEvent(_RCVData);
}
}
catch (Exception ex)
{
_RCVData = null;
_PortLog.LogHandler("RFIO", Assembly.GetEntryAssembly().GetName().Version.ToString(), 1, this.ToString(), "RecievedData()", ex.ToString());
}
}
modified 17-Feb-14 1:46am.
|
|
|
|
|
Probably, the problem is that serial data is just that: serial. Which means that it arrives one character after another (in reality, one bit after another, but for your purposes you can ignore that), not as a solid "block" of data as it does when you deal with internet or LAN packets.
With serial data, you will get a DataReceived event fired when there is one of more characters received by the computer: it will not wait until they have all been read, because it does not know when the message ends.
So if you want to acquire a complete message, it may take a number of events to get it all - or it might take just one, depending on the load on your PC at that time.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Thanks for your valuable reply, I am not able to find out that how many times event got fired. Can you give any idea.
Thanks
|
|
|
|
|
Keep a class level variable and increment it by one each time?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: With serial data, you will get a DataReceived event fired when there is one of more characters received by the computer: it will not wait until they have all been read, because it does not know when the message ends.
Not plain right - The SerialPort class has properties to either fire the event after a certain number of bytes was received, or after a certain character was read (which is essentially why the ASCII code contains stuff like STX and ETX chars).
Women are waiting for love and men are waiting for women. - Wolf Wondratschek
|
|
|
|
|
Um...you might find ASCII predates .NET a bit - I was using STX/ETX and so forth back in the 70's...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I wasn't saying that these characters where introduced for .Net - These characters were introduced to know when a sequence of unknown size ends, and since this has proven it is adapted within .Net.
Women are waiting for love and men are waiting for women. - Wolf Wondratschek
|
|
|
|
|
Instead of ReadExisting() you can also use ReadTo :
void arduinoBoard_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string data = arduinoBoard.ReadTo("\x03");
string[] dataArray = data.Split(new string[]
{"\x02", "$" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string dataItem in dataArray.ToList())
{
WeatherDataItem weatherDataItem = new WeatherDataItem();
weatherDataItem.FromString(dataItem);
weatherDataItems.Add(weatherDataItem);
}
if(NewWeatherDataReceived != null)
{
NewWeatherDataReceived(this, new EventArgs());
}
}
I used the byte 0x03 in my example because I know that a command always ends with 0x03, but this depends on the communication partner. Depending on your communication protocol you may need to replace 0x03 with something else, but in general you should either know the length of the message you receive, or with which byte it is going to end (In case you only know the message length you'd need to use SerialPort.ReadBytes ).
The reason for that was stated correctly by OriginalGriff: Serial communication means that the information (text) is transmitted byte by byte, and therefore ReadExisting may not grab all the available bytes in the input buffer, because they were not transmitted yet.
I recommend you to read this article[^], it may help your understanding of serial communication and serial ports.
Women are waiting for love and men are waiting for women. - Wolf Wondratschek
|
|
|
|
|
Hello everyone,
I';m trying to learn c# and would like to start a project doing a desktop application. The problem is I don't know where or how to start.
Ive been doing online courses and watch alot of videos on the subject that have given me a understaning of how C# works but when I want to create something new im just clueless what to do.
it almost feels that programming is not for me but im not ready to give up just yet!!
So for my question: Does anyone have any suggestion how to continue ? how do I get the right midset to acually getting started with a project? Is there any course, video or book that you think would be a good idea for me ?
I would be so grateful for any help I can get.
Also i'm sorry if this post has any errors in the placment, structure or there are any information I left out in the question.
This is the first time im trying to learn to code and first time asking any kind of question programing wise and feel abit lost. please be kind despite my ignorance
Thank you for your time and have a good day!
|
|
|
|