|
I'm not sure I understand your problem; I assume you have peripherals (bar code scanners) with a serial interface, and are using USB-to-serial cables. If so, I don't see where the USBSerialEmulator comes in:
1.
a USB-to-serial cable comes with its driver, making the serial port available to Windows and all interested apps. You typically can have as many as you want, and choose the port name.
2.
bar code readers just emulate a keyboard, all they do is emit a string corresponding to the bar code, so a little code snippet based on SerialPort should be good.
3.
furthermore most bar code scanners can be taught to add a prefix and a postfix string of your choice, so you could e.g. prefix something that identifies the scanner, and postfix a newline combination.
If all the above applies, simply have one serial data receiver handle all the scanners, look for the prefix, and dispatch the actual data to the appropriate destination.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry....We have USB scanners and connect them as USB then use the USBSerialEmulator.
|
|
|
|
|
I may have to read up on this a bit.
Who created USBSerialEmulator? and what is the scanner's vendor, make and model?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Honeywell 3820...the emulator is Honeywell also. We have delt with Honeywell support on this and their response is "You cannot connect two scanners to the same PC using the USBSerialEmulator." We've tried, but it's just flaky. And when they switch the scanners around...its messy. We'd like plug and play with the ability to use both sections of the application at the same time on the same PC with two different scanners....that is why I think the original programmer tried the COM port.
|
|
|
|
|
Well, if they are positive it isn't supposed to work for more than one, you should drop them and go for regular, non-USB, scanners, with a good old RS232C interface; then use USB-to-serial cables, with its driver, etc, as I laid out in my original reply. Make sure the model you choose has prefix/postfix capability.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
The problem with that is we have about 35 scanners at $200+ each. I had a simliar idea.
|
|
|
|
|
If Honeywell can't solve it, it will cost you.
With what you have, it is either keep the hardware and have new software, maybe a totally new USB driver or something (is anyone going to do that with a total cost of ownership significantly less than 7000$?); or replace the hardware, add USB cables (15 to 25$ each), and a little piece of code in your app.
I have done some bar code projects before, and I know which way to choose here; rather than spending money locking you deeper into a suboptimal choice, I'd go for the open approach that works just fine.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
That is why I want to use USB and get rid of the com port configuration in our custom .NET pack&ship appl. I don't think your following my post. I've already came to the conclutions you've suggested. The com port configuration is what is the problem. I would like to implement USB into the application and if you have any suggestions on how then please suggest something
|
|
|
|
|
AFAIK you need a good USB driver then; and that would be specific to both the peripheral and the operating system (some drivers survive a single major Windows upgrade). I don't think it is up to a customer to create drivers for a manufacturer's hardware, but if you were to go that route: I wish you good luck. And I wouldn't mind reading a CP article when it's done.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi!
I have some problems with the BackGroundWorker. The code can make the DoWork fire, but when the DoWork complets the RunWorkerComlpeted do not fire.
What is wrong?
Peter Schwennesen
Public Class Test
Public WithEvents BGW As System.ComponentModel.BackgroundWorker
Private Test As Boolean
Public Function FindAllMachines() As Boolean
Test = False
BGW = New System.ComponentModel.BackgroundWorker
AddHandler BGW.DoWork, AddressOf BGW_DoWork
AddHandler BGW.RunWorkerCompleted, AddressOf BGW_RunWorkerCompleted
BGW.RunWorkerAsync()
System.Threading.Thread.Sleep(30000)
Return Test
End Function
Private Sub BGW_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
e.Result = True
End Sub
Private Sub BGW_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
Test = True
End Sub
End Class
|
|
|
|
|
I see nothing wrong. Try adding a Console.WriteLine("BGW done") in the completion handler.
BTW: rather than waiting a fixed amount of time, you should use proper synchronization; have a look at AutoResetEvent, and its Set() and WaitOne() methods.
|
|
|
|
|
You do realize that you put your main thread to sleep for 30 seconds, right? In that time, your main thread cannot respond to the Completed event that returns immediately upon execution. So, you're async method is going to return True to the Completed event, but since the main thread is asleep for 30 seconds, nothing will happen until then.
Anyway, your function FindAllMachine should not be returning a value, it should be a Sub. You should be getting that value form the RunWorkerCompleted event. After all, why would you sleep the main thread so it can't respond to mouse events while you're looking for machines??
|
|
|
|
|
Yeah, this is a bad idea. Dave Kreskowiak is right. But if you still want that try following code:
Do
If Not BGW.IsBusy Then
Return True
End If
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(100)
Loop
Use <pre lang="vb"> Visual Basic Code Here.</pre>
modified on Tuesday, January 11, 2011 9:07 AM
|
|
|
|
|
Hello,
I have a problem, I have to include video from a network camera in an application in VB. NET, I purchased the SDK for the camera, brings examples to implement the video but in C#, I translated the code using a translator online , but there are a couple of lines of code that give me error and not know how to solve them
- An error tells me: "Not allowed a reference to the class "..." when your assembly is connected by way NO-PIA"
-other: "The kind of interoperability "..."class can not be embedded. Use the interface of its place"
- "Public ...()Event is an event and not be called directly. Use the RaiseEvent statement to raise an event"
- "The delegate EventHandler requires an expression ...." AddressOf "or a lambda expression as its single argument constructor
Sorry for my bad english, hope you can help me
Thank you
|
|
|
|
|
Hard to tell without seeing the code. Are you sure you have added proper references to the interop assemblies? Also don't use converters as they only work for simple code.
Best wishes,
Navaneeth
|
|
|
|
|
First thank you for answear, well when you say "Are you sure you have added proper references to the interop assemblies?", do you mean add the references in the menu project add references right?, yes I think I have add all references.
well I think I have a problem in translation this line in C# to VB .NET I dont know how make it right
m_device_conector.ConnectResult += New ...videosdk.device.deviceconectorEvents_ConectResultEventHandler(OnConnectResult)
I dont know if I need delegates, addressof or something like that...
can you help me?
thanks
|
|
|
|
|
Denis9999 wrote: I dont know ...
You could look it up in your VB.NET book. Or in MSDN. Or search some of the CP articles.
What you need probably looks like this:
AddHandler m_device_conector.ConnectResult, AddressOf OnConnectResult
|
|
|
|
|
Thanks for answear, I have a problem it appears me
-Not allowed a reference to the class DeviceConnectorClass when your assembly is connected by way NO-PIA
what means that of "NO-PIA"?? How can I solve it??
because this error I can see if it works the solution "addhandler...."
anybody knows how to solve it??
Thank you very much
|
|
|
|
|
NoPia blog posts[^]
have a read of that maybe it can help you?
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
You could try passing it through a .net converter to change from one to the other.
Google will provide you with many choices, some free, some, better ones, at a charge.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Dave the only problem is that the OP original did this and I think someone else had mentioned that the converters aren't 100% accurate in converting complex pieces of code
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
Of course not, but it is a start.
He will have to go over it, but if he does it block by block it is an achievable task.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Thank you all for your answears, I have used a converter to translated, but there is an error that I wrote before and I dont know how to solve it. can anyone help me?
|
|
|
|
|
Just curious...
Are you aware what a PIA is?
Have you contacted the vendor of the SDK you purchased to ensure that they even support VB? Sure, you may be able to get it to work, but things can be just different enough to make it tough sometimes and if they are not going to 'support it' then you might be in the hot heat.
|
|
|
|
|
Can anyone help me solve this problem? It give me this error at crypto.close. Any Suggestions?
Try
'checking to make sure the text box isn't null'
If (Decrypt_TextBox.Text = "") Then
MessageBox.Show("Need to put in the file location or select file in grid for decryption")
Else
'declaring string for file'
Dim filename As String
'Getting the file name that is selected'
filename = getFilename()
'Starting to abstract the data from the database'
database.ConnectionString = "Data Source = [name of database].db3;"
database.Open()
Dim command As SQLite.SQLiteCommand
Dim sqlstatement As String
command = database.CreateCommand
'The following will get the bytes of the file'
Dim filesize As Integer
sqlstatement = "SELECT FileSize From [table name] WHERE FileName=@file;"
command.CommandText = sqlstatement
command.Parameters.AddWithValue("@file", filename)
Dim reader As SQLite.SQLiteDataReader
reader = command.ExecuteReader
filesize = reader.GetValue(0)
reader.Close()
MessageBox.Show(filesize)
Dim data(filesize) As Byte
'The following should get the data'
sqlstatement = "SELECT FileData FROM [table name] WHERE FileName=@file;"
command.CommandText = sqlstatement
command.Parameters.AddWithValue("@file", filename)
Dim buf() As Byte
'This gets the file from the database'
reader = command.ExecuteReader
'The following should get the file back to its original form'
buf = reader.GetValue(0)
MessageBox.Show(buf.Length)
'This is go into the Safe and retrieve file'
Dim datawrite As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)
datawrite.SetLength(0)
datawrite.Write(buf, 0, buf.Length)
datawrite.Close()
reader.Close()
Dim fileinput As New System.IO.FileStream("filename", IO.FileMode.Open, IO.FileAccess.ReadWrite)
'specific file output location wiht proper extension'
Dim fileoutput As New System.IO.FileStream(Decrypt_TextBox.Text & "\" & filename, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
'The next line makes sure that the file is empty'
'Declaring variables for encryption'
Dim buffer(4096) As Byte 'Holds the bytes for processing
Dim BytesProcessed As Double 'running count for bytes that are processed'
Dim filelength As Double = fileinput.Length() 'Length of file coming in where intEnd will be greater than intStart'
Dim bytesinblock As Integer 'current bytes in block'
Dim crypto As CryptoStream
'Declaring crypto service provider'
Dim scRijndael As New System.Security.Cryptography.RijndaelManaged
'setting up progress bars
Encrypt_ProgressBar.Value = 0
Encrypt_ProgressBar.Maximum = 100
crypto = New CryptoStream(fileoutput, scRijndael.CreateDecryptor(key, IV), CryptoStreamMode.Write)
While BytesProcessed < filelength
'reading the file'
bytesinblock = fileinput.Read(buffer, 0, 4096)
'writing the file to cryptoStream'
crypto.Write(buffer, 0, bytesinblock)
'updating bytes processed'
BytesProcessed = BytesProcessed + CLng(bytesinblock)
'equation for updating bytes in block'
Decrypt_ProgressBar.Value = CInt((BytesProcessed / filelength) * 100)
End While
crypto.Close()
fileoutput.Close()
fileinput.Close()
MessageBox.Show("File is done decrypting")
Decrypt_ProgressBar.Step = 0
Decrypt_ProgressBar.Value = 0
Decrypt_TextBox.Text = ""
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
Return 1
|
|
|
|
|