Re: Open port USB with vb.net in PDA | Abrir el puerto USB con vb.net en PDA

From: KM (konstmor_at_nospam.yahoo.com)
Date: 04/27/04


Date: Tue, 27 Apr 2004 15:42:37 -0700

Edgar,

This is definitely wrong newsgroup for your PDA related questions. You would better off trying something like
microsoft.public.pocketpc.

As Slobodan mention, you better check the return and error (GetLastError.) codes from each API call. And use \\.\COM?".

Also, WriteFile related.. When you send a string from VB to an API, use ByVal prefix. When ByVal precedes a string argument
variable, the address of the null-terminated string data is sent to the procedure. When ByVal is not included, a string descriptor
is sent to the called DLL procedure.
You call may look like: intBF=WriteFile(idPort, ByVaL bytBuffer, bytBuffer.Length, 1024, ByVaL 0&)

--
 KM,
    BSquare Corporation
> Hi everybody |<es>| Hola  a  todos
>
> I have a problem with a USB; I canīt open USB port with VB.net for PDA
> |<es>| Tengo un problema con el USB; no he logrado abrir el puerto USB con
> VB.net
>
> I need send text to a printer RS232 but i canīt;
> |<es>|  Necesito enviar texto a una impresora RS232 pero no puedo
> I have USB to RS232 (Chip PL2303)
> |<es>|  Tengo un cable USB a RS232 (Chip PL2303)
>
> can you help me?  can you tell me how open the port?
> |<es>|  Prodrian ayudarme? podrian decirme como abrir el puerto?
>
> I use CreateFile() and WriteFile() but it dosen't works
> |<es>| He usado CreateFile() y WriteFile() pero no funcina
>
> I also use CreateFile() and DeviceIOcontrol() but it dosen't works
> |<es>| Tambien he usado CreateFile() y DeviceIOcontrol() y no funciona
>
>
> Example Code
>
>     <DllImport("coredll.dll")> _
>     Private Shared Function CreateFile(ByVal lpFileName As String, _
>         ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, _
>         ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition
> As Integer, _
>         ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As
> Integer) As Integer
>     End Function
>     <DllImport("coredll.dll")> _
>     Private Shared Function DeviceIoControl( _
>             ByVal hDevice As Int32,  ByVal dwIoControlCode As Int32, _
>             ByRef lpInBuffer As Int32, ByVal nInBufferSize As Int32, _
>             ByRef lpOutBuffer As String, ByVal nOutBufferSize As Int32, _
>             ByRef lpBytesReturned As Int32,  ByRef lpOverlapped As Int32) As
> Int32
>     End Function
>   <DllImport("coredll.dll")> _
>     Private Shared Function WriteFile( _
>         ByVal hFile As Int32,  ByVal Buffer As Byte(),  ByVal
> nNumberOfBytesToWrite As Int32, _
>         ByVal lpNumberOfBytesWritten As Int32,  ByVal overlapped As Int32)
> As Int32
>     End Function
>
> Function PrinterDeviceIO()
>     idPort = CreateFile("COM9:", GENERIC_READ Or GENERIC_WRITE, 0, 0,
> OPEN_EXISTING, 0, 0)
>
>     intBF = DeviceIoControl(idPort,  FILE_GENERIC_WRITE,  2048,  1,
> strValue, strValue.Length,  intReturn, intOver)
> End Function
>
> Function PrinterWriter()
>     idPort = CreateFile("COM9:", GENERIC_READ Or GENERIC_WRITE, 0, 0,
> OPEN_EXISTING, 0, 0)
>
>     intBF = WriteFile(idPort, bytBuffer, bytBuffer.Length, 1024, 0)
> End Function
>
>
>
>
>


Relevant Pages

  • Re: Nokia phone via USB ???
    ... usb storage devices. ... storage.model = 'CRD-254V' (string) ... mode, MP3 mode, or storage mode. ...
    (comp.os.linux.hardware)
  • Re: 1-wire to USB converter that can use 1820s directly
    ... use a bog standard USB/1wire commercial converter/adapter if it ... will drive the string of 1820s fine, and it appears that that will ... They are all powered from the USB. ... And parasitic power of the 1820s should work fine, ...
    (comp.home.automation)
  • HAL consuming a lot of CPU
    ... consuming a lot of CPU here on my -current revision 189278. ... The only hardware that I saw something strange is my Sun type 7 usb ... info.category = 'oss' (string) ... net.interface_up = false (bool) ...
    (freebsd-current)
  • Re: WriteFile is sending screwy data to the Serial Port
    ... will give you the number of character positions in the string. ... Your call to WriteFile is syntactically correct. ... Since MultiByteToWideChar works perfectly, while WriteFile ... > bool DoTxData(HWND hWnd, char *txData, DWORD dwTxDataSize) ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Nokia phone via USB ???
    ... usb storage devices. ... storage.model = 'CRD-254V' (string) ... storage.model = 'USB SD Reader' ... mode, or data storage mode. ...
    (comp.os.linux.misc)

Loading