Jump to content


Photo

Acessando Porta Serial Com Vs.2005 E Framework 2.0


  • Faça o login para participar
5 replies to this topic

#1 Carlos Rodrigo

Carlos Rodrigo

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 31/07/2006, 11:18

Srs,

Com a chegada da nova biblioteca do framework 2.0 foram agregadas novós objetos de conexão com a porta serial, que era utilizada anteriormente uma biblioteca RS232 ou o OpenNetCF para a construção de aplicações que utilizavam esse tipo de interação.

O objeto novo dessa versão utilizado por mim para escrever dados em uma conexão serial com uma impressora de textos é o System.IO.Ports.SerialPort

Você pode inicializar todos as configurações da porta no construtor do objeto ou setar posteriormente esses dados,o mais aconselhavel por mim por ser mais facil de dar um melhor suporte na codificação.


No exemplo abaixo mando imprimir diretamente na serial um código de uma etiqueta de códigos de barra em formato CPCL. ( os códigos da etiqueta são textos puros interpretados por impressoras desse padrão, ex. Zebra)

Antes de abrir a comunicação com a porta erifico se a mesma encontra-se aberta e caso esteja, fecho a mesma possibilitando que haja o auto flush dos dados que estão em buffer e abro a conexão posteriormente.

Após a abertura da porta serial, apenas uso o metodo Writeln para imprimir o texto que eu desejar. Ao final da escrita eu fecho a porta.

Fiz também um tratamento básico de erros onde caso haja alguma excessao uma janela sera exibida com a mensagem da excessao é exibida.

Esse código abaixo funiona tanto para aplicação cliente PC como windows mobile. Vale lembrar também que usei esse codigo para imprimir em uma conexao bluetooth e funcionou corretamente pois o bluetooth quando estabelce alguma conexão com um dispositivo disponibiliza uma porta serial lógica para transmitir dados

Private Sub btnImprime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprime.Click
		Me.btnImprime.Enabled = False
		'Dim swErr As IO.StreamWriter
		Try

			porta_serial = New IO.Ports.SerialPort



			With porta_serial
				.PortName = "COM" & Me.nudCOM.Value.ToString

				.BaudRate = 9600
				.DataBits = 8
				.Parity = IO.Ports.Parity.None
				.StopBits = IO.Ports.StopBits.One
				.WriteTimeout = 4000

				If .IsOpen Then .Close()
				.Open()

				   .WriteLine("! 0 200 200 210 3")
					.WriteLine("CENTER")
					.WriteLine("TEXT 4 0 0 50 TESTING 001")
					.WriteLine("COUNT 1")
					.WriteLine("TEXT 7 0 0 100 Barcode Value is 123456789")
					.WriteLine("COUNT -10")
					.WriteLine("BARCODE 128 1 1 50 0 130 123456789")
					.WriteLine("COUNT -10")
					.WriteLine("JOURNAL")
					.WriteLine("PRINT")

			End With

			Me.porta_serial.Close()
		Catch ex As IO.IOException
			MessageBox.Show("Erro::" & ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)

		End Try

		Me.btnImprime.Enabled = True
	End Sub


#2 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 17/09/2017, 19:18

Soft Cialis cheap cialis Cephalexin Dog Thirsty Vardenafil Information Cialis 20mg De Propecia Regrow Low Cost Cialis 2.5mg Daily cialis Propecia Generic Finasteride 5 Alpha Reductase
Discount Coupon For Celebrex cialis Cialis 10 Mg Pharmacie
Viagra Mail Order No Prescription
Gel De Kamagra <a href=http://cialtobuy.com>cialis</a> Treating Bronchitis With Amoxicillin

#3 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 03/10/2017, 22:51

Its known as the right of withdrawal.to make whatever enquiries are deemed necessary to process this application including sharing account and loan data with other credit unions consumer reference agencies andor Union Check. quick loans responsiblelending. You always hear about how these loans put consumers and borrowers at great risk.What you would normally pay for years of standard repayment years Personal Loans The Ultimate Guide to Getting the Money You Need Julia Dugas Lulu Press Inc ISBN BiBTeX EndNote RefMan Personal Loans The Ultimate Guide to Getting the Money You Need advanced fee personal amount of money area of personal asset bad Credit balance due Better Business Bureau budget cosigner Collateral attached Consider Consolidate Cost Credit history Credit rating Credit report Credit Score debt Consolidation default dollar amount educate eligible Federal Trade Commission fee personal loan help you find high risk higher interest rate important individuals issues lender immediately lending Companies lending institution loan Collection officer loan Companies loan offered Loans Personal loans look maximum loan amount month monthly payment Obtaining a personal Online lenders Online personal loan pay a higher paycheck personal loan application personal loan Collection personal loan insurance personal loan officer personal loan payment personal loan Scams PerSOnal LOanS Personal poor Credit processing fee repay the loan repayment reputable Company responsibility Secured loans situation Sure type of Collateral type of loan types of personal unsecured personal loan variety of needs victims websites A personal loan is money you borrow from a lender for your own private use.
Propecia Canadian Cialis Soft cialis viagra levitra kaufen rezeptfrei Cialis 5 Mg Generico Online Cialis Puo Dare Dipendenza
Water Pills On Line Pharmacy Como Conseguir Cytotec En Usa cialis price Propecia Decadencia De Pelo
Viagra Achat En Ligne En Saint Animal Amoxicillin 50mg Bmp 193 viagra online pharmacy Cialis Generique Tadalafil Tamoxifen Citrate Online Isotretinoin With Next Day Delivery Cod Only
Viagra Pay With Paypal Buy Wellbutrin Xr Without Rx levitra 20 mg cost walmart Canada Pharmacies Online Why Amoxicillin In Dogs Amoxicillin Cough Seraph And

#4 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 13/10/2017, 02:06

Buy Thyroxine Online India Buy Brand Name Viagra Online Canada Achat Kamagra Canada viagra Cialis Montreal Viagra Generico Vendita Zithromax And Running
Half Dose Propecia Levitra Laboratoire Bayer viagra Prix Ciprofloxacin 10mg En Pharmacie Finasteride 5mg Side Effects

#5 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 30/10/2017, 07:47

Macrobid With Free Shipping Overseas Cialis 20mg Tunisie viagra Escrow Refills Prednisone Purchase Generic Propecia

#6 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 17/11/2017, 03:02

Buying Generic Fluoxetine In Internet Viagra Como Se Toma Viagra Et Insuffisance Cardiaque levitra online overnight delivery Cephalexin For Dog Isotretinoin Price Find On Line Viagra Likor Rezept




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq