Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 20:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon Bits
Post new topic   Reply to topic View previous topic :: View next topic
Page 10 of 12 [168 Posts]   Goto page: Previous 1, 2, 3, ..., 8, 9, 10, 11, 12 Next
Author Message
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Fri 11 Nov 2011, 15:37    Post subject:  

Hey big_bass,

Where's that dance? Razz

r
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Sat 12 Nov 2011, 15:26    Post subject:  

GatorDog; Do they even allow dancing on this forum? Laughing

big_bass; Pjot showed code to input a file in one read.
More codey of course, but BaCon does it all by itself, no Bash.
Would go good in a function library I think. BaCon needs standard libraries.
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sat 12 Nov 2011, 18:40    Post subject:  

Quote:
Do they even allow dancing on this forum?

Sorry, my baD. (mea culpa) Crying or Very sad

GatorDog
Back to top
View user's profile Send private message 
Volhout


Joined: 28 Dec 2008
Posts: 391

PostPosted: Thu 15 Dec 2011, 12:40    Post subject: COM port
Subject description: support in BaCon
 

I am trying to communicate with an oscilloscope via serial port (38.4kbaud).
I blindly tried the OPEN "COM1:38400" command, but that does not work.
I am using WARY 5.1.4.1 and have the dev. pack installed.

Anyone tried this ?

What do I have to do to read and write text strings (SCPI commands) through the COM port using BaCon ??

Regards,

Volhout
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Thu 15 Dec 2011, 13:22    Post subject:  

Hey Volhout
take a look here I dont want to double post
it will get you closer and there is a link for more stuff using the serial port
*'llI try to dig up some very old code I used to connect my ti-85 calculator using the serial port
I didnt write the serial code but tested *(I did write code for the parallel port though)* it to be working using Qbasic

http://basic-converter.proboards.com/index.cgi?board=code&action=display&thread=191
http://www.faqs.org/docs/Linux-mini/IO-Port-Programming.html#ss6.3
http://www.easysw.com/~mike/serial/serial.html
Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Thu 15 Dec 2011, 14:14    Post subject:  

Dear Joe,

Thanks for posting those links here. I think plenty of people would like to learn how to control serial and parallel ports. USB is another kettle of fish Smile You have also put up some useful info on puppylinux.info, if my memory serves me right

With kind regards,
vovchik
Back to top
View user's profile Send private message 
Volhout


Joined: 28 Dec 2008
Posts: 391

PostPosted: Wed 21 Dec 2011, 06:20    Post subject:  

Big Bass,

Thanks for the links, but they are not very useful for me.
Your example (parallel port output) uses the SYSTEM command from BaCon to call a compiled C program. The other links show snippets of C functions that could be compiled to a library.
If I could program in C and compile it, I would probably do the whole project in C. This info is simply over my head (capacity)

Does make me feel stupid though...

Volhout
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 21 Dec 2011, 10:12    Post subject:  

Volhout wrote:
Big Bass,

Thanks for the links, but they are not very useful for me.
Your example (parallel port output) uses the SYSTEM command from BaCon to call a compiled C program. The other links show snippets of C functions that could be compiled to a library.
If I could program in C and compile it, I would probably do the whole project in C. This info is simply over my head (capacity)

Does make me feel stupid though...

Volhout


Hey Volhout
you did this which is many times more complex
http://www.murga-linux.com/puppy/viewtopic.php?t=69647&start=48

first you had to compile the driver "ftdi_drv.bac
you also had to link a lib
Quote:

BaCon driver for FTDI USB-SERIAL convertor chips. Uses compiled libraries
' from FTDI : libftdi-0.19. When compiled (./configure, make, make install)
' this library generates libftdi.so.1


you used peek and poke and pure HEX
then IMPORTED thats a lot of work so
since you can do that this will be easy for you Smile

the way I did it was easy sorry if I did a poor job explaining the easy part
I compiled a C app and showed the needed compile command to do it

so you just cut and paste that in a terminal
* I also linked a pre compiled binary of the C code
you dont have to think in C code because
once you have the binary in the path
it does all the dirty work of communicating with the system automatically

then instead of using HEX
you output in decimal the decimal value of the HEX
you want to send or receive to the port

you can PM me at any time
I would like to learn how to do this with the USB !
so we can share our fun Very Happy


P.S is the USB code you posted
the final working code you use?
if not could you post the source that does compile correctly

Joe

edited typo code for could

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though

Last edited by big_bass on Wed 21 Dec 2011, 13:41; edited 1 time in total
Back to top
View user's profile Send private message 
Volhout


Joined: 28 Dec 2008
Posts: 391

PostPosted: Wed 21 Dec 2011, 12:14    Post subject: FTDI driver for bitbang mode
Subject description: Yes, it works
 

Hi Big Bass,

Yes, I got the bitbang driver working for the FTDI FT245BM chip.
I'll list the code I used here. The project was abandoned when I readlized that the FTDI chip would be really slow to generate I2C in bitbang mode. But if you need 8 IO pins from USB, you can use my code.

Code:

'-------------------------------------------------------------
'
'     program to test the driver glue layer in ftdi_drv.bac
'
' 2011-09-02                                     Harm de Leeuw
'--------------------------------------------------------------

INCLUDE "ftdi_drv.bac"

LOCAL data TYPE unsigned char
LOCAL mask TYPE unsigned char

PRINT "connect to USB module with FT245BM"
'<D0,D3> output, <D4,D7> input
mask = 0x0F               
ft245bm_open (mask)
PRINT "device connected, enabling bitbang mode"

PRINT "start banging"
FOR data = 0 TO 254
   'write 0x00 .... 0xFE
   ft245bm_poke (data)
   'and read back, but <D4,D7> read actual input values
   PRINT RIGHT$(HEX$(ft245bm_peek()),2)   
NEXT data

PRINT "stop banging, disable bitbang mode"
ft245bm_close ()

END


It uses a second BaCon program, I call the driver module.

Code:

'---------------------------------------------------------------------------
' BaCon driver for FTDI USB-SERIAL convertor chips. Uses compiled libraries
' from FTDI : libftdi-0.19. When compiled (./configure, make, make install)
' this library generates libftdi.so.1
' 2011-09-02                          Harm de Leeuw
'---------------------------------------------------------------------------
' Version
'   0.1   Supports open(mask), poke(byte), and close()
'       0.2     Added peek() function
'---------------------------------------------------------------------------
TRAP LOCAL

' Import some calls first
CONST library$ = "libftdi.so.1"

' Get the functions from the library
IMPORT ftdi_init(long) FROM library$ TYPE int
IMPORT ftdi_usb_open(long,int,int) FROM library$ TYPE int
IMPORT ftdi_get_error_string(long) FROM library$ TYPE char* ALIAS ftdi_get_error_string$
IMPORT ftdi_read_chipid(long,long) FROM library$ TYPE int
IMPORT ftdi_usb_close(long) FROM library$ TYPE int
IMPORT ftdi_deinit(long) FROM library$ TYPE void
IMPORT ftdi_write_data(long,long,int) FROM library$ TYPE int
IMPORT ftdi_set_bitmode(long,unsigned char,unsigned char) FROM library$ TYPE int
IMPORT ftdi_disable_bitbang(long) FROM library$ TYPE int
IMPORT ftdi_usb_get_strings(long,long,long,int,long,int,long,int) FROM library$ TYPE int
IMPORT ftdi_read_pins(long,long) FROM library$ TYPE int

CONST TYPE_AM = 0
CONST TYPE_BM = 1
CONST TYPE_2232C = 2
CONST TYPE_R = 3
CONST TYPE_2232H = 4
CONST TYPE_4232H = 5

CONST BITMODE = 0x01

' BaCon does not know types so we define
' a RECORD with the needed members
RECORD ftdic
    ' USB specific
    LOCAL usb_dev TYPE long
    LOCAL usb_read_timeout TYPE int
    LOCAL usb_write_timeout TYPE int
    ' FTDI specific
    LOCAL type TYPE int
    LOCAL baudrate TYPE int
    LOCAL bitbang_enabled TYPE unsigned char
    LOCAL *readbuffer TYPE unsigned char
    LOCAL readbuffer_offset TYPE unsigned int
    LOCAL readbuffer_remaining TYPE unsigned int
    LOCAL readbuffer_chunksize TYPE unsigned int
    LOCAL writebuffer_chunksize TYPE unsigned int
    LOCAL max_packet_size TYPE unsigned int
    ' FTDI FT2232C requirecments
    LOCAL interface TYPE int
    LOCAL index TYPE int
    ' Endpoints
    LOCAL in_ep TYPE int
    LOCAL out_ep TYPE int
    ' General
    LOCAL bitbang_mode TYPE unsigned char
    LOCAL eeprom_size TYPE int
    LOCAL error_str TYPE char*
    LOCAL async_usb_buffer TYPE char*
    LOCAL async_usb_buffer_size TYPE unsigned int
END RECORD

'-----------------------------------------------------------------------
SUB ft245bm_open (unsigned char io_mask)
'-----------------------------------------------------------------------
' this function initializes the FTDI 245 BM chip attached to the USB bus
' of the PC in bitbang mode (8 bit wide IO port). The io_mask define the
' data direction ("1"=out, "0"=in).
' timing: every byte write takes 1 milisecond, regardless CPU speed.

   IF ftdi_init(ADDRESS(ftdic)) < 0 THEN
          PRINT "ftdi_init failed"   
          END 1
   END IF
   ret = ftdi_usb_open(ADDRESS(ftdic), 0x0403, 0x6001)
   IF ret < 0 THEN
          PRINT "unable to open ftdi device: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
   ret = ftdi_set_bitmode(ADDRESS(ftdic), io_mask, BITMODE)
   IF ret < 0 THEN
          PRINT "unable to set bitmode: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
END SUB

'-----------------------------------------------------------------------
SUB ft245bm_poke (unsigned char data)
'-----------------------------------------------------------------------
' this function sends out a byte to the 8 bit wide io port of the ftdi
' 245bm chip. The actual data output is masked by the io_mask set in
' the init command.
   ret = ftdi_write_data(ADDRESS(ftdic), ADDRESS(data), 1)
   IF ret < 0 THEN
          PRINT "unable to write: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
END SUB


'-----------------------------------------------------------------------
SUB ft245bm_close ()
'-----------------------------------------------------------------------
' this function disconnects the ftdi 245bm chip from the USB bus.
' first bitbang mode is disabled, putting the io pins in tristate.
   ret = ftdi_disable_bitbang(ADDRESS(ftdic))
   IF ret < 0 THEN
          PRINT "unable to close ftdi device: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
   ret = ftdi_usb_close(ADDRESS(ftdic))
   IF ret < 0 THEN
          PRINT "unable to close ftdi device: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
   ftdi_deinit(ADDRESS(ftdic))
END SUB

'-----------------------------------------------------------------------
FUNCTION ft245bm_peek () TYPE unsigned char
'-----------------------------------------------------------------------
' this function reads the 8 io pins from the ftdi 245bm chip, and returns
' the value. The value read is depending on the mask set when opening the
' connection.
   LOCAL data TYPE unsigned char
   ret = ftdi_read_pins(ADDRESS(ftdic), ADDRESS(data))
   IF ret < 0 THEN
          PRINT "unable to read: ", ret, " (", ftdi_get_error_string$(ADDRESS(ftdic)), ")"
          END 1
   END IF
   RETURN data
END FUNCTION

'-----------------------------------------------------------------------


The ftdi library (libftdi.so.1) is the one I compiled from ftdi source code. Get it from their website. If you used WARY 5.1.4 I can send you the .so file, otherwise you have to compile it yourself.

Good luck with it. You are free to post this anywhere on the BaCon website as a working solution. This location may not be the best place to have this posted.....

Regards,

Volhout
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 21 Dec 2011, 14:00    Post subject:  

Quote:
Good luck with it. You are free to post this anywhere on the BaCon website as a working solution. This location may not be the best place to have this posted.....


Hey Volhout

I wouldnt want to start a thread in BaCon with your code
because if an edit is needed it would be better for you to be the author of the thread

however there are a few Bacon users here and if anyone asks for USB info I will kindly link them to your code here
thanks for posting your code !

Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
Volhout


Joined: 28 Dec 2008
Posts: 391

PostPosted: Thu 22 Dec 2011, 05:35    Post subject: FTDI project posted  

Hi BigBass,

I have posted the latest version of the project on the BaCon forum.

http://basic-converter.proboards.com/index.cgi?action=display&board=code&thread=196&page=1

Hope it is to someones benefit.

Regards,

Volhout
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Thu 22 Dec 2011, 10:12    Post subject:  

Dear Volhout,

Totally great job. Thanks.

With kind regards,
vovchik
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Fri 30 Dec 2011, 20:42    Post subject:  

Hey rod @GatorDog


I decided to go over your GUI examples

man, I am having a lot of fun with it
thanks for posting so much good stuff
and sharing your notes
they helped me understand the BaCon GUI part
much better

thanks !
Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sat 31 Dec 2011, 18:19    Post subject:  

Thanks Big_bass,

After we get through the Holidays, maybe I'll have some time
to get back and do a little coding Very Happy

Happy New Year All!

GatorDog

_________________

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Mon 09 Jan 2012, 23:45    Post subject:  

.
### Hope you all had good holidays and best new years wishes to you all.!
.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 10 of 12 [168 Posts]   Goto page: Previous 1, 2, 3, ..., 8, 9, 10, 11, 12 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1068s ][ Queries: 12 (0.0076s) ][ GZIP on ]