|
I have an array list of serial port configuration. i want to call these configuration later in the program. So how can i call the configuration from array ?
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
using System.ComponentModel;
using System.Data;
using System.Drawing;
public class Class1
{
public Class1()
{
}
public ArrayList SerialPortContainer = new ArrayList();
private string config_file = "C:/achu/config.txt";
private string PhoneNumber;
private string ServiceCentre;
public bool test()
{
try
{
string line;
TextReader tr = new StreamReader(config_file);
System.IO.StreamReader objReader;
objReader = new System.IO.StreamReader(config_file);
int NumberOfLines = 0;
while ((line = tr.ReadLine()) != null)
{
NumberOfLines++;
}
string[] ListLines = new string[NumberOfLines];
for (int i = 0; i < NumberOfLines; i++)
{
ListLines[i] = objReader.ReadLine();
string[] values = ListLines[i].Split(new char[] { '$', '#' });
string[] PortSplit = values[0].Split(new char[] { ':', '#' });
string PortName = PortSplit[1];
string[] BaudSplit = values[1].Split(new char[] { ':', '#' });
int BaudRate = Convert.ToInt32(BaudSplit[1]);
string[] BitsSplit = values[2].Split(new char[] { ':', '#' });
int DataBits = Convert.ToInt32(BitsSplit[1]);
string[] NumberSplit = values[3].Split(new char[] { ':', '#' });
PhoneNumber = NumberSplit[1];
string[] SerNumberSplit = values[4].Split(new char[] { ':', '#' });
ServiceCentre = SerNumberSplit[1];
SerialPort serialPort1 = new SerialPort();
serialPort1.PortName = PortName;
serialPort1.Handshake = Handshake.RequestToSend;
serialPort1.BaudRate = BaudRate;
serialPort1.DataBits = DataBits;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
serialPort1.DtrEnable = true;
serialPort1.Open();
SerialPortContainer.Add(serialPort1);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
public void ATTest()
{
string val = Convert.ToString(SerialPortContainer[1]);
MessageBox.Show(val);
}
}
|
|
|
|
|
[Cannot understand the question clearly]...hmmm..Ok if you want to access those array values in the ATTest() method,declare those array variables as global variables i mean at class level not inside the method Test().
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Using a field in the class, like myConfigArray? If you have to use it in another class think about using static fields that are public.
Regards
Sebastian
|
|
|
|
|
hiii
First Option:
Pass The Array to the function...
Second Option:
Declare The Arryas as "Class" Private Members.....
|
|
|
|
|
Hello there.
I'm developing a C# application that interracts with a contactless smart card readers ( MiFare 1k and MiFare 2k readers), but since those kind of card readers dont support PS/SC the WinScard API won't help.
(For a start ... i need a list of all connected contactless smart card readers )
So i suppose i should loop through all connected usb devices and send some APDU command so they can give their status ( identify them if they are contactless smart card readers )
Is that the right way to do that ? If someone has any information about this issue ... i'm opened to any suggestions
I've been searching around the web for about 3 whole days and i'm nowhere .... Please help me
|
|
|
|
|
You'd normally go to the manufacturer and get the Software Development Kit to do this. I can't believe a manufacturer put out a piece of hardware and didn't supply an SDK so you can use it in your own code.
|
|
|
|
|
Thank you for your response.
Unfortunatly my task is to develope an access management system that interracts with all card readers in a specific building. And unfortunately the card readers in that building are not from the same manifacturer. ( The only thing in common between them is that they are conctactless card readers and reader MiFare 1k and MiFare 2k cards. )
Yes, i have a sdk which works fine with the specific reader provided to me, but ... i dont think it will "work" with the other devices.
So I was thinking of a universal low level usb communication with the card readers, hoping they "work the same way behind the scenes". And folowing that logic i got stuck here http://www.codeproject.com/script/Forums/View.aspx?fid=1649&select=2906409&tid=2904097[^]
modified on Monday, February 2, 2009 3:37 AM
|
|
|
|
|
Well, unfortunately for you, the commands, responses, and communication protocol between the different card readers are, more-than-likely, not the same. You're going to end up writing a seperate communication module for each card reader you have. The SDK for each of them is the only thing that's going to simplify this process.
|
|
|
|
|
Thank you for your response!
I was afraid , but not surpsised by your answer.
Since those devices don't support PS/SC, there is no universal way to achieve my goal.
However when i pass this hell, i'm going to write an article about contactless cards and contactless card readers i codeproject (actually ... as surprising as it sounds ... there is not even one GOOD article about that in the web - i've been researching like a whole week )
Thanks again for the information !
Best regards, Hristiyan ....
|
|
|
|
|
I have been through this hell, and it is possible to write a program that will process a couple of different cards. However, I have done it with C++ and not C#. I will try to give you an idea of how to do this in C#.
What I did, was that I had a Mifare and a 15693 contactless mix. The readers were made by entirely different companies. Each reader has its own dll and there is unmanaged code to and from the reader, so in C# you must use delegates for you methods.
You must also add the references (dlls to the project). Then you create a reader object for every kind of reader that you have dlls for.
I had a dll which was able to read and code to differentiate the various RFID technologies, and using that bit of code snippet, I was able to determine what dlls and reader objects to use.
The SDKs were fairly expensive, but I can give you a C++ code snippet on how to determine the various technologies: (you will notice that this can determine 1so15693, 14443A, 14443B, iso8000, felica
CIso_benchDlg::CIso_benchDlg(CWnd* pParent )
: CDialog(CIso_benchDlg::IDD, pParent)
{
m_tagid = _T("");
m_type = _T("");
m_iso15693 = FALSE;
m_iso14443A = FALSE;
m_iso14443B = FALSE;
m_iso18000 = FALSE;
m_felica = FALSE;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CIso_benchDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_DETECT, m_button);
DDX_Text(pDX, IDC_TAGID, m_tagid);
DDX_Text(pDX, IDC_TYPE, m_type);
DDX_Check(pDX, IDC_CHECK1, m_iso15693);
DDX_Check(pDX, IDC_CHECK2, m_iso14443A);
DDX_Check(pDX, IDC_CHECK3, m_iso14443B);
DDX_Check(pDX, IDC_CHECK4, m_iso18000);
DDX_Check(pDX, IDC_CHECK5, m_felica);
}
BEGIN_MESSAGE_MAP(CIso_benchDlg, CDialog)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_DETECT, OnDetect)
END_MESSAGE_MAP()
BOOL CIso_benchDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
CenterWindow(GetDesktopWindow());
SetTimer(IDC_TIMER, 20, NULL);
UpdateData(FALSE);
return TRUE;
}
void CIso_benchDlg::OnTimer(UINT nIDEvent)
{
if (detect){
char tag_id[600];
tag_id[0]=0;
int temp=0;
int success=0;
m_iso15693=false;
m_iso14443A=false;
m_iso14443B=false;
m_iso18000=false;
m_felica=false;
C1_disable(); C1_enable();
if(success=get_14443A(&my_tag_14443A)) {
if(my_tag_14443A.type==MIFARE_CL) m_type="MiFare Classic";
else if(my_tag_14443A.type==MIFARE_UL) m_type="MiFare UltraLight";
else if(my_tag_14443A.type==MIFARE_DF) m_type="MiFare DESFire";
else m_type="14443A";
m_iso14443A=true;
C1_disable(); C1_enable();
}
if(temp) success=true;
if(temp=get_15693(&my_tag_15693,NULL)) {m_type="ISO 15693"; m_iso15693=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(m_type!="ISO 15693" && (temp=get_18000(&my_tag_18000))) {m_type="ISO 18000"; m_iso18000=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(temp=get_IC(&my_tag_IC, IC_15693, false, false)) {m_type="INSIDE"; m_iso15693=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(temp=get_IC(&my_tag_IC, ISO_14443B3, false, false)) {m_type="INSIDE"; m_iso14443B=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(temp=get_IC(&my_tag_IC, IC_14443B, false, false)) {m_type="INSIDE"; m_iso14443B=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(temp=get_14443B(&my_tag_14443B)) {m_type="14443B"; m_iso14443B=true; C1_disable(); C1_enable();}
if(temp) success=true;
C1_disable(); C1_enable();
if(temp=get_14443B_SRI(&my_tag_14443B)) {m_type="14443B"; m_iso14443B=true; C1_disable(); C1_enable();}
if(temp) success=true;
C1_disable(); C1_enable();
if(temp=get_14443B_SR176(&my_tag_14443B)) {m_type="14443B"; m_iso14443B=true; C1_disable(); C1_enable();}
if(temp) success=true;
if(temp=get_FeliCa(&my_tag_FeliCa)) {m_type="FeliCa"; m_felica=true; C1_disable(); C1_enable();}
if(temp) success=true;
if (success){
success=0;
if(m_type=="ISO 15693") {
m_tagid="";
for(int i=0;i<my_tag_15693.id_length;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_15693.tag_id[i]);
m_tagid=tag_id;
}
else if(m_type=="MiFare Classic" || m_type=="MiFare UltraLight" || m_type=="MiFare DESFire" || m_type=="14443A") {
m_tagid="";
for(int i=0;i<7;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_14443A.tag_id[i]);
m_tagid=tag_id;
}
else if(m_type=="INSIDE") {
m_tagid="";
for(int i=0;i<8;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_IC.tag_id[i]);
m_tagid=tag_id;
}
else if(m_type=="ISO 18000") {
m_tagid="";
for(int i=0;i<my_tag_18000.data_length;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_18000.data[i]);
m_tagid=tag_id;
}
else if(m_type=="FeliCa") {
m_tagid="";
for(int i=0;i<my_tag_FeliCa.id_length;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_FeliCa.tag_id[i]);
m_tagid=tag_id;
}
else if(m_type=="14443B") {
m_tagid="";
for(int i=0;i<my_tag_14443B.id_length;i++) sprintf(tag_id,"%s%02X",tag_id,my_tag_14443B.tag_id[i]);
m_tagid=tag_id;
}
UpdateData(FALSE);
}
else{
if (m_tagid == "SEARCHING...") {
m_tagid = "SEARCHING.";
m_type = "SEARCHING.";
}
else {
m_tagid = "SEARCHING...";
m_type = "SEARCHING...";
}
UpdateData(FALSE);
}
}
CDialog::OnTimer(nIDEvent);
}
void CIso_benchDlg::OnDetect()
{
if(detect==FALSE) {
if(!C1_open_comm())
{
m_tagid = "Failed To Connect..";
m_type = "";
UpdateData(false);
C1_close_comm();
return;
}
if(!C1_enable())
{
m_tagid = "Failed To Enable..";
m_type = "";
UpdateData(false);
C1_close_comm();
return;
}
detect = TRUE;
m_button.SetWindowText(L"STOP DETECTION");
m_tagid = "";
m_type = "";
m_iso15693=false;
m_iso14443A=false;
m_iso14443B=false;
m_iso18000=false;
m_felica=false;
UpdateData(false);
} else {
C1_disable();
C1_close_comm();
detect = FALSE;
m_button.SetWindowText(L"DETECT!");
m_tagid = "";
m_type = "";
m_iso15693=false;
m_iso14443A=false;
m_iso14443B=false;
m_iso18000=false;
m_felica=false;
UpdateData(false);
}
}
Hope this helps.
|
|
|
|
|
we can populate Web Browser Control using DataFilePath and set the xml file path to DataFilePath property. i want to know how to populate web browser control with xml instead of using DataFilePath property of Web Browser Control. if possible the please let me know with sample code snippet.
tbhattacharjee
|
|
|
|
|
Save the XML to a temporary location and set DataFilePath accordingly?
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Hi all,
I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not?
Thanks and Regards.
|
|
|
|
|
SqlDataAdapter.Update(DataSet) returns an System.Int32 value which gives the number of rows successfully updated from the DataSet.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Thanks for your reply but it can't work or I can not understand how to use this. Please describe with a little example. It fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).
|
|
|
|
|
Use the Update overloaded one...i mean
SqlAdapter sa = new SqlAdapter();
int j = sa.Update(ds,"TableName");
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Hi.............
Its Simple....
Just Keep the return value....
if it zero ... then No change....
else thats much change....
Just click If u wantto Know more...
http://msdn.microsoft.com/en-us/library/at8a576f.aspx[^]
|
|
|
|
|
Thanks for your reply but I can not understand how to use this. I am using given refrence link but it fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).
|
|
|
|
|
It sounds like the basic issue is one of incompetence. Have you looked at the link provided and the code in the MSDN and compared it to your own ? If you want us to fix your code, have you considered posting it, so we can see where your error is ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
This is my code, where the problem occurs.
SqlDataAdapter da = new SqlDataAdapter("UPDATE CompanyInfo SET CompName='abc' where CompID='" + CompID.Text.Trim() + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
int gh = da.Update(ds, "CompanyInfo");
Exception fires on that code is ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'.").
Please suggest for the wrong code.
Thanks and Regards
|
|
|
|
|
Hi every body,
Here i face a problem,the problem is i develop a pdf viewer,now i uninstall acrobat reader from my pc.
when i open a web page that contain pdf, open a new window with pdf viewer application. I want to open in IE like acrobat reader in IE.
Please help me.
using C#,.Net frame work 2.0
Sanjoy Bagchi
S/W Engineer
|
|
|
|
|
Sample.aspx:
Script File:
document.getElementById('ifr').src='LoadPdf.aspx';
In LoadPdf.aspx.CS .PageLoad Event U call This Method
private void WritePdf(byte[] pdfContent)
{
try
{
Response.ContentType = "application/pdf";
Response.OutputStream.Write(pdfContent, 0, (int)pdfContent.Length);
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
throw ex;
}
}
|
|
|
|
|
Sir,in my pc there is no acrobat reader. there install my program to view pdf. i wrote your program but the error msg came like this
"
An invalid character was found in text content. Error processing resource 'http://localhost:1891/WebSite1/LoadPdf.aspx'. L...
%
"
please help me...
Sanjoy Bagchi
S/W Engineer
|
|
|
|
|
Hello everybody
I read the articles related to establish a connection between webcam and C#.
I have a webcam that has the following parameters
1-Image resolution RGB24 320*240....RGB24 1280*1024
I420 320*240...I420 640*480
I want to know how can i access these setting in my program.I want to change the mode and resolution
manually in my program
Regards
|
|
|
|
|
I had created a small application from the article http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx?fid=447248&df=90&mp p=25&noise=3&sort=Position&view=Quick&fr=51&select=2421069
But while the control is in "foreach loop", the CPU usage increases near about 80-90%. I just want to reduce that CPU usage.
The other thing is if I try to manipulate the web page text, the original text is visible to user for a fraction of second, and then the replaced text is visible to user. I don't want that original text is visible to user. I just want to replace the original text of a web page on the fly, for the I am using DWebBrowserEvents2_ProgressChangeEventHandler.
In the foreach loop I was identifying the tagname and replacing the innertext of tag element.
I want the replaced text should be seen directly by the user. But there was some delay in displaying the replaced text. i.e., initially for a fraction of second the original text is visible to user before the replaced text.
How can I avoid these two problems and the output should be...
1. User should be seen directly the replaced text but not the original text of a web page.
2. The CPU usage should be reduced which is caused because of "foreach loop".
As well as I was trying to identify individual tag elements using
http://www.codeproject.com/KB/shell/enum_selected_elements.aspx?
in which IMarkupServices interface is used. Here also same problem occurs. There is some delay in displaying the replaced text on the web page.
But the main problems are:
1. Delay in display of replaced text on a web page when it is visible to the user
2. The CPU usage is high which is caused because of "foreach loop".
I manipulated by innertext property of HTML tag elements in a foreach loop.
This has been developed from
http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx?fid=447248&df=90&mp p=25&noise=3&sort=Position&view=Quick&fr=51&select=2421069
How can i solve this.........
Any suggestions would have been appreciated.
I had spent so much time on these but are of no use.
I tried all these links but output is samea nd my problems can't be avoided.
http://social.msdn.microsoft.com/Forums/en-US/Offtopic/thread/1c835fad-66c0-46ba-b499-3ba7090bd660/
http://www.eggheadcafe.com/community/aspnet/2/10073309/how-to-reduce-cpu-usage-w.aspx
|
|
|
|
|