16,022,417 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Nishikant Tayade (Top 30 by date)
Nishikant Tayade
30-Jun-18 7:00am
View
public class Program
{
public delegate int MyOwnDelegate(byte[] pBuffer);
public static void Main(string[] args)
{
CurrentDataDataRespParser client = new CurrentDataDataRespParser();
client.testEvent += new Program.MyOwnDelegate(new Program().TestMethod);
DOF2.sendBytes();
Console.ReadKey();
}
public int TestMethod(byte[] pBuffer)
{
Console.WriteLine("Inside the Test Method");
return 0;
}
}
//CurrentDataDataRespParser is a class where I have declared an event.
public class CurrentDataDataRespParser
{
public event MyOwnDelegate testEvent;
public CurrentDataDataRespParser()
{
}
public int Parse(byte[] pBuffer)
{
testEvent?.Invoke(pBuffer); return pBuffer.Count();
}
}
//and below is the class from where parse method will be called ,which will invoke the event, what I really want is to execute the method TestMethod written in Program class.
public class CurrentDataPacketRespDecoder:PacketDecoder
{
public CurrentDataDataRespParser data_parser_instance;
public CurrentDataPacketRespDecoder()
{
data_parser_instance = new CurrentDataDataRespParser();
}
public override void decode(byte[] pBuffer, byte[] outBuffer
{
if (data_parser_instance == null) { return; }
**here giving call to parse method**
int consumedBytes = data_parser_instance.Parse(pBuffer);
}
Nishikant Tayade
28-Jun-18 8:58am
View
Thanks!You are right and it is working perfectly,but problem is
client.Parse(Encoding.ASCII.GetBytes("Hello"));//Here in my code I am not directly calling the parse method,there is another method someClass.SendBytes();
which internally goes through many classes and one of the method of that class gives call to Parse method.
When i am debugging again it is showing DataReceived as null.
Nishikant Tayade
28-Jun-18 8:13am
View
I am creating subscriber in Main method in class Program.
public class Program
{
public static void Main(string[] args)
{
DataReceivedEventSubscriber test = new DataReceivedEventSubscriber ();
DOF2.sendBytes();//this method sends byte array to Parse method in above code which raises event.
Console.ReadKey();
// port.Close();
// port.Dispose();
}
}
}
//The DataReceived is showing null,when I debug the code
Nishikant Tayade
26-Jun-18 4:59am
View
As you said byte can only be in the range 0 to 255.So I did these and now it's working perfectly.
byte[] s = BitConverter.GetBytes(sum);
if (s[0] == value)
{
start_index = 0;
ret_pair.Item2.AddFirst(outBuffer.ElementAt(start_index + 2));
Console.WriteLine("Inside if block");
}
Nishikant Tayade
14-Jun-18 2:35am
View
I used inno setup,as it allows you to add the dependencies on your own.So i added
all the files including SQLite.Interop.dll and it works very well.
Nishikant Tayade
12-Jun-18 4:39am
View
Yes,I have installed System.Data.SQLite through package manager in my project,
and its working on my machine,but issue is when i run my setup on different machine and try to save data entered on button click.
Nishikant Tayade
12-Jun-18 2:02am
View
DirectoryInfo di=System.IO.Directory.CreateDirectory("C:\\Users\\admin\\AppData\\Roaming\\tthhSensorCalibrator");
string logFilename = System.IO.Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData), di+"\\databaseFile.db3");
This is working on my machine.Database file in folder specified is getting created.
But when i try to run it on other machine then it shows
Could not found part of path.
C:\\Users\\ACCEL\\AppData\\Roaming\\tthhSensorCalibrator\\databaseFile.db3
Nishikant Tayade
12-Jun-18 0:10am
View
Deleted
Done.Thanks for helping me out.
Nishikant Tayade
11-Jun-18 8:41am
View
It worked,that was some if-else problem.
The special folder list also contains Program files ,how can i get access to that folder or can i not.
Nishikant Tayade
11-Jun-18 8:30am
View
string logFilename = System.IO.Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.Favorites), "databaseFile.db3");
I tried this and it successfully creates database file,but it is empty,no table.
Nishikant Tayade
11-Jun-18 5:39am
View
I tried the different folder (Documents folder specifically) but it creates the file but still there is no table.
Nishikant Tayade
11-Jun-18 5:29am
View
Tried a folder but still no results
Nishikant Tayade
8-Jun-18 1:33am
View
@EricLynch The solution that you have provided is completely right,in my serial port communication class I am using a new implementation of Ring Buffer provided on GitHub
https://github.com/xorxornop/RingBuffer/blob/master/PartiallyConcurrent/RingBuffer.cs
I don't know how many bytes of packet i will receive and that is the main issue that's why i am trying to use the Circular/Ring buffer,
public class DataReceiveHandle
{
public static int MAX_PACKET_LENGTH = ChannelDataCount.count;
public static bool newData = false;
public static int rxOffset = 0;
public static int rxWrite = 0;
public static int rxRead = 0;
public static byte[] rxBuffer = new byte[MAX_PACKET_LENGTH];
public static byte[] rxPackage = new byte[MAX_PACKET_LENGTH];
public static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
if (e.EventType != SerialData.Chars) return;
SerialPort port = (SerialPort)sender;
int bytesCount = port.BytesToRead;
port.Read(rxBuffer, rxOffset, bytesCount);
SequentialRingBuffer rBuffer = new SequentialRingBuffer(4096, rxBuffer, true);
rxWrite=rBuffer.CurrentLength;
// rxOffset = rxOffset + bytesCount;
byte[] tempArray = new byte[256];
tempArray=rBuffer.ToArray();
foreach (byte item in tempArray)
{
Console.WriteLine(item);
}
}
I tried different way but was unable to do an correct implementation, can you please have look at it?
Nishikant Tayade
6-Jun-18 1:56am
View
@ChanderParkashMourya as you said "when any response will come from "COM3" port then the event will be called."
But what i want is that it should just stop asking when first response comes, in that case "In data receive" will be there only once,then again ask for data and so on.
is it possible?
That's why i was trying to unsubscribe.
Nishikant Tayade
5-Jun-18 5:46am
View
Thanks.Gonna show this to boss.
Nishikant Tayade
5-Jun-18 4:55am
View
As the data receive event get fired multiple times it brings that chunk of data,so instead of waiting till full data is received(which may be time costly)
I want to check what is the data send by serial port and start working on only that limited data.
That's why i am asking about circular buffer.
Nishikant Tayade
5-Jun-18 4:17am
View
Ok.Can you please help me now?
Nishikant Tayade
5-Jun-18 2:49am
View
@MehdiGholam can you please share an solution or another way out of this problem now?
Nishikant Tayade
5-Jun-18 2:36am
View
@MehdiGholam As there is no circular buffer implementation provided by default
How can i read the data send by serial port into Circular buffer(provided on Git) so to read it,parse it?
for details:
https://stackoverflow.com/questions/49593013/how-can-i-read-and-calculate-serial-port-with-circular-buffer-c-sharp
Nishikant Tayade
5-Jun-18 0:01am
View
@JochenArndt Thanks,I got it.Is there any way of using circular buffer or dynamic array to store the the data that is sent by serial port at a time and then parse what is available in the buffer and then again put data into it and so on.
Nishikant Tayade
4-Jun-18 8:39am
View
@JochenArndt I understood what you said,but though I can get whole data and then do processing on it.What i want to do is get that chunk of data and process it.
Nishikant Tayade
4-Jun-18 4:14am
View
Thanks @JochenArndt.I can work on this now.
Nishikant Tayade
4-Jun-18 2:30am
View
I know its like spoon feeding but as a noob its little bit confusing,I googled but it is all over the places.please give an code snippets.
Nishikant Tayade
4-Jun-18 1:59am
View
@OriginalGriff Thanks for the response,but what do you meant by building state machine?Could you please give an code snippet,so that it will be better to understand.
Nishikant Tayade
2-Jun-18 8:20am
View
Already done that.But still the same
Nishikant Tayade
2-Jun-18 8:12am
View
I did what you said earlier,now the program is getting compiled and executing but it shows output only when it is in debug mode,otherwise it just get terminated after executing without any output on the console.
Nishikant Tayade
2-Jun-18 7:55am
View
I have made some changes and now its is showing the output.Thanks for the response.
Nishikant Tayade
2-Jun-18 7:29am
View
Deleted
Can you please share this in code?(Sorry if i am asking a lot)
Nishikant Tayade
2-Jun-18 7:13am
View
so i tried it again and it is giving output as 224.
But when i sent the same hex( $D0$F2$FF$00$06$C7) with terminal then it is giving output as E0 F2 01 00 3C 25 82 00 00 EA 95 20 01 2E 23 17 70 20 01 2C 23 17 70 20 01 36 23 17 70 20 01 2E 23 17 70 23 03 E8 23 03 E8 23 03 E8 23 03 E8 23 03 E8 23 03 E8 23 03 E8 23 03 E8 8F
that 224 is E0,but what about rest of it?
Nishikant Tayade
2-Jun-18 7:03am
View
I tried it,but still not working.Can you please elaborate.It will be really helpful
Show More