|
dashingsidds wrote: I just wanted everyone to know that this thread is active and not dead
Threads don't die. If someone has an answer, or chooses to respond, they will. You adding a response just shows you are impatient and demanding. Again, these forums are not paid support but are voluntary.
dashingsidds wrote: use a better language than using words like "damn"
I'll damn well use damn wherever I please damnit.
Since you are rude and impatient and can't follow the guidelines and etiquette of this site, you're on your own now.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The original poster just posted a reminder and did not specifically demand an answer from "Mark Nischalke" and the language was far more superior than your reply. You could have altogether ignored the post.
|
|
|
|
|
Shameel wrote: posted a reminder
Obvuously you are as ignorant of proper ettique here as the OP was.
Shameel wrote: You could have altogether ignored the post.
As could you have ignored this post as well. So what's your point?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
He also cross-posted -- another no-no.
|
|
|
|
|
I am developing an application using the serial port pin controls when a switch is open or closed, what I do is connect a switch between the pins RTS and CTS (output RTS pin7 to the input CTS Pin8). As a true RTS I have it all the time, pressing the switch changes the state of CTS and through the event PinChanged pick up the change of state and write it down.
The code used is similar to that attached
PrivateSub SerialPort1_PinChanged(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialPinChangedEventArgs) Handles SerialPort1.PinChanged
If e.EventType = IO.Ports.SerialPinChange.CtsChanged Then
class Escribelog(“TZ”)
EndIf
EndSub
But do not get me run this event, even though I look for www, I find that it is advisable not to put too much code in that event, since it must resolve what has very quickly to be available again, which can not be changed controls, but I see no reason why one can not do what I want. But even if ordinary VB in me a working PC.
I read something that perhaps signals the sense that I use have changed, so that as this email on a PDA, when I set the RTS to true, I'm really not one but putting 0, so that pressing connect switch but both RTS to CTS 0, and therefore I do not detect anything, but do not know if this is true or I've misunderstood.
You know how I can find out why it does not work this lucky code.
Thank you very much
|
|
|
|
|
You may have any of the following issues, or combination thereof:
1.
AFAIK you need to open the serial port, and obviously you need to wire an event handler to it, for the handler to become active at all.
2.
connecting RTS to CTS may or may not work, one is an input pin, one is an output pin; if the unconnected input pin has the same logic level as the output pin, then connecting them together won't change a thing. So your scheme will only work for one specific value of the RTS pin. I never can remember the levels, so you would have to look up the details.
3.
almost all asynchronous handlers, and the SerialPort ones for sure, run on ThreadPool threads. Which means they cannot reliably access any GUI Controls. You can (for debugging purposes) include a MessageBox.Show(), that should work; but you can't simply do myLabel.Text="CTS has changed";
This article[^] provides more information about that.
Some remarks:
- a mechanical switch will "bounce", so for throwing the switch once, you are likely to get several "pin changed" events.
- all serial port events get queued; if your event handler takes longer, additional events will get queued and will call your handler with some delay, so you loose the real-time behavior. (That would also be true with you clicking a Button that has a slow handler).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hello Luc, thanks for this information, but after that, I think I should explain my situation, and sorry for my english:
•On the project I open de serialport, and I haven’t problem with that, and also I connect the two pins whit a wire and a switch.
•I read others projects that use the same concept for running ok, but I don’t see its code, also I read that the two pins are the same logic: I probe to connect positive and negative signal RTS and in both cases the event PinChanged no jump
•I know the situation of the serialport event cannot access any GUI Controls, so I don’t use it. In my event I only stop a timer, write in a log and finally I restart the timer. I use this timer to write to a log periodically, and I think my problem is in this timer, but I delete it and the even still not working
After that I don’t know where to go
About of remarks, when I get running my project ok, I study the problems whith “bounce” or delay, but I think I will not problems with it, because is not a critical solution.
|
|
|
|
|
OK, some more points you should check:
- you are using the correct SerialPort;
- the SerialPort is open;
- it has CanRaiseEvents true;
- you are using the right pins;
- your switch is operational;
- measure the voltages you are getting between the GND pin and any relevant pin;they must be OUTSIDE the range [-3,+3] Volt and throwing the switch must change the input voltage from one side to the other.
- try it with as simple a PinChanged handler as possible (a single MessageBox.Show)
If all else fails, show us code.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hello Luc, on response at your message, I review the pointS you remarks,and:
-I use the correct serial port, COM1, because I open it and if I change the RtsEnable the true at false, the RTS pin 7 change his signal sign
-I review the pin another time, ans I use the correct, pin 7 and 8
-When I change the RtsEnable the true at false, the RTS pin 7 change to 6.7V at -5.7V, in both cases is this signal that I connect to CTS Pin 8
-Finally I probe with as simple a PinChanged handler as possible and I continue whithout response
The only point what I don't know to do is the use of "CanRaiseEvents" How can i do?
Thanks for all
I send my code:
Imports System
Imports System.IO
Imports System.Threading
Public Class Control_entrada
Dim bitRTS As Boolean
Dim bitDTR As Boolean
Dim estadoCTS_OLD As Boolean
Private Sub comm1_PinChanged(ByVal sender As Object, ByVal e As System.IO.Ports.SerialPinChangedEventArgs) Handles comm1.PinChanged
''Timer1.Enabled = False
MessageBox.Show("SI")
''Call ctrl_log.EscribeLog("TZ")
''Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
' Utilizamos un Control Timer para mostrar en los text el dia y la _
'hora del sistema. La propiedad intervalo del control timer esta en 1000 milisegundos
Call ctrl_log.EscribeLog("CT")
End Sub
Private Sub cmdRTS_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRTS.Click
If bitRTS Then
cmdRTS.Text = "Activar control puerta (RTS)"
bitRTS = False
Call ctrl_log.EscribeLog("PP")
Else
cmdRTS.Text = "Activado control puerta (RTS)"
bitRTS = True
Call ctrl_log.EscribeLog("AP")
End If
'AQUI SE ACTIVA LA SEÑAL DE RTS PARA VIGILAR LA APERTURA DE LA PUERTA
'esta señal sera constantemente 1, y en caso de abrir la puerta el interruptor la conecta al pin CTS
'que pasara de ser 0 a ser 1 y es lo que detectaremos para escribir en el log la apertura de puerta
'comm1.RtsEnable = bitRTS
comm1.RtsEnable = True
End Sub
Private Sub cmdparar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdparar.Click
If comm1.IsOpen Then
comm1.Close()
End If
Me.Text = "Puerto - cerrado"
Call ctrl_log.EscribeLog("PG")
cmdAbrir.Enabled = True
cmdRTS.Enabled = False
cmdDTR.Enabled = False
Timer1.Enabled = False
End Sub
Private Sub cmdAbrir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAbrir.Click
' por si el puerto ya está abierto por otra aplicación
On Error Resume Next
comm1.Open()
If comm1.IsOpen Then
Me.Text = "Puerto - abierto"
Call ctrl_log.EscribeLog("AG")
cmdAbrir.Enabled = False
cmdRTS.Enabled = True
cmdDTR.Enabled = True
''Timer1.Enabled = True
Else
Me.Text = "no se puede abrir el puerto"
End If
End Sub
End Class
Public Class ctrl_log
Public Shared Sub EscribeLog(ByVal tip_msg As String)
Dim direccionArchivo As String
direccionArchivo = ".\ctrl\Ficherito.txt"
Dim sw As StreamWriter = File.AppendText(direccionArchivo)
Dim txt_log As String
Dim hora As String
Dim fecha As String
Try
hora = Format(TimeOfDay, "HH:mm:ss")
fecha = Format(DateTime.Today, "dd/MM/yyyy")
txt_log = fecha & " " & hora
Select Case tip_msg
Case "PC"
txt_log = txt_log & ": Puerta cerrada" + System.Convert.ToChar(13)
Case "PA"
txt_log = txt_log & ": Puerta abierta" + System.Convert.ToChar(13)
Case "PP"
txt_log = txt_log & ": Parada proc puerta" + System.Convert.ToChar(13)
Case "AP"
txt_log = txt_log & ": Arranque proc puerta" + System.Convert.ToChar(13)
Case "PG"
txt_log = txt_log & ": Parada proc general" + System.Convert.ToChar(13)
Case "AG"
txt_log = txt_log & ": Arranque proc general" + System.Convert.ToChar(13)
Case "CT"
txt_log = txt_log & ": Control" + System.Convert.ToChar(13)
Case "TZ"
txt_log = txt_log & ": Estoy en evento" + System.Convert.ToChar(13)
Case "T1"
txt_log = txt_log & ": Estoy en evento 1" + System.Convert.ToChar(13)
Case "T2"
txt_log = txt_log & ": Estoy en evento 2" + System.Convert.ToChar(13)
Case "T3"
txt_log = txt_log & ": Estoy en evento 3" + System.Convert.ToChar(13)
End Select
sw.Write(txt_log)
sw.Flush()
sw.Close()
Catch exFile As Exception
sw.Close()
MsgBox(("Cannot open " & exFile.ToString()))
Return
End Try
sw.Close()
End Sub
End Class
|
|
|
|
|
Hi,
I haven't studied all that, just a few comments and ideas:
1.
there is a property SerialPort.CanRaiseEvents; I don't recall having needed it ever, and it seems read-only. After opening the port, you should read it and make sure it returns true.
2.
if you enable some kind of hardware handshake the driver may change the way your control pins get used; so make sure SerialPort.HandShake is set to Handshake.None
3.
if button cmdRTS is meant to toggle the RTS output pin, then I would simplify it to:
Private Sub cmdRTS_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRTS.Click
comm1.RtsEnable = NOT comm1.RtsEnable
If comm1.RtsEnable Then
Call ctrl_log.EscribeLog("PP")
Else
Call ctrl_log.EscribeLog("AP")
End If
End Sub
4.
if you were to connect RTS and CTS (without a switch), then each click on the cmdRTS button really should raise a PinChanged event.
5.
I have no idea how the serial port settings get initialized; sometimes it feels like a port remembers its most recent settings (at the Windows level). So I tend to set everything explicitly, taking a dozen lines of code, right after the SerialPort.Open()
6.
Are you using real serial ports? on your PC's motherboard? on a plug-in card?
or are you using an USB-to-serial cable?
the latter might behave a bit different, depending on the manufacturer. It also often needs a vendor specific driver. Maybe there is a bug; maybe it requires you to transmit a character (SerialPort.Write) before it updates the control pins; remember: it will try and collect commands and data in USB data packets, it probably doesn't send a packet for each character. I know it is a bit slower (but quite capable of normal 19200 Bd and probably higher too).
Hope any of this helps.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hello Luc, I review some points you remarks and:
1. I found the property CanRaiseEvents, but i don’t get using it, it’s a private property and if I put “SerialPort.” I don’t recover it. How can I using it?
2. The HandShake is set to compone
3. I’m using a real serial port, of my PC's motherboard. But how I Developer for smart devices, I’m using the Visual Studio’ emulator, through the activesync
I try to probe others points what you remarks and I'll tell you
Thanks for all
|
|
|
|
|
Hi Experts,
In one of my project functionality I had a requirement of needing a list of all the sections in my app.config file. I was wondering if there is a class (or anything for that matter) inbuilt in .net which would return a collection of sections present in a app.config configuration file.
For example if my app.config is having two sections say "appSettings" and "ConnectionString" then that class should return me a List<string> with 2 values "appSettings" and "ConnectionString".
If anyone is aware of anything regarding this then please let me know.
Thanks in advance!
Regards,
Samar
|
|
|
|
|
|
Thanks Richard for the quick response. It really helped a lot!
Regards,
Samar
|
|
|
|
|
I'm working with DevExpress' XtraReports, and I'm noticing that the ORDER in which tables are added to the DataSet adversely affects a master-detail report. The master table must be added first. I would think that the table order would be irrelevant, having correctly established the relationships between tables.
Anyone else experience this issue with .NET? Or does this seem to be a DevExpress bug?
Marc
|
|
|
|
|
I can't recall ever coming across this issue. I would lean toward it being an issue with DevExpress.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Dear Friends.
I want to resize a monochrome bitmap (every pixel can only contains 0 or 1) to another size (like 32*32 to 30*50).
I can do it with GDI+ but I want to do it WITHOUT USING ANY CLASS LIKE GDI+. (only loop , for , if , etc.)
How can I do it?
Regards.
Mehdi Ghiasi
|
|
|
|
|
You can't run anything under .NET without using some .NET classes, so I'll assume the classes you want to avoid are the graphical ones only. Then this is the recipe:
1. study the specification of your input image format, maybe it is a BMP file;
2. read the input, probably into a byte array;
3. now turn it into some in-memory representation that you feel comfortable with;
4. perform the resize, i.e. create a new bitmap in memory
5. study the specification of your output image format, maybe it is a PNG file;
6. generate your output image by converting it into the output format.
You probably could combine some of the steps. You will need a lot of bit manipulations, so make sure you are fluent in masking, shifting, and the like. For the resizing itself, you may choose a nearest-neighbor approach, or alternatively you may want to study different interpolation algorithms, bi-cubic is popular.
If you need an extra challenge, you may implement compression, e.g. the one used in the JPEG file format.
The alternative to all of the above is less than 10 lines of code, based on the Bitmap class.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
No! I have a monochrome bitmap in an integer array table and I want to resize it into a new array WITHOUT GDI+ or any Class that Resizes the image For me. I want to know How It Works!
Regards.
Mehdi Ghiasi
|
|
|
|
|
The result probably won't look very good under these conditions; here are two examples (data in binary):
1.
an image with a width of 8 pixels, one row containing
00101110
scaled up by a factor of 2, it becomes
0000110011111100
0000110011111100
So the result is a "pixelated" image, bits just got replicated, as there is no extra information available.
2.
the reverse operation: an image with a width of 16 pixels, two rows containing
0x0x1x0x1x1x1x0x
xxxxxxxxxxxxxxxx
(you can put a 0 or 1 at any of the 'x' positions) scaled down by a factor of 2 it could become
00101110
which again does not look anywhere near the same as the original as 75% of the information got thrown away.
And that was only the very simple case of a scale by 1/2 or 2/1.
As I said before, you will need a lot of bit manipulations, so make sure you are fluent in masking, shifting, and the like. For the resizing itself, you may choose a nearest-neighbor approach.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
So how can I scale a 100x100 image into 150x150 ?
Regards.
Mehdi Ghiasi
|
|
|
|
|
only double even OR odd bits ...
|
|
|
|
|
I want to answer you, but I want to do it without using any words or code. If you get my telepathic message you should be all set.
|
|
|
|
|
Hi,
I'm trying to figure out how to accept a rejected character in a masked text box. I am using a "Masked Textbox" for the person's last name and to ensure all alpha characters, I'm using "L?????????????????", however if the person's last name has a quote in it, the masked text box is rejecting it but in code I want to accept it. I see I can where I can check the character in the Reject event, however I can not cancel the reject.
Any suggestions how to do this, other than using a Keydown event and accepting only the characters I want?
Thank you,
Glenn
|
|
|
|
|
|