![]() ![]() The serial port you’re using may not already be set to the baudrate you desire.An alternative method of sending the string without these trailing characters using the set command is shown below. The first five byte values in the sequence are just the letters of the word “hello”, but the last three are the space, carriage return and line feed characters. I tested this myself by capturing the transmitted bytes using a microcontroller and then echoing their numerical values back to the screen – the values were: “104 101 108 108 111 32 13 10”. The string that gets sent in the above example is actually 8 bytes long because it includes the trailing space character after the word “hello” as well as carriage return and line feed characters.( SerialSend provides an easy alternative method of sending strings to whatever the highest numbered available COM port is, which can be very useful.) If you’re using a USB-to-serial converter, this number may change over time, especially if you plug the device into different USB sockets. You need to know the number of the COM port you want to send to.There are a couple of potential snags though: So the string “hello” gets sent to the serial port rather than to the screen. Here however, its output is redirected (using the “>” character) to the special filename “COM1”, which is actually a serial port rather than a file on disk. The echo command is typically used to display a string in the console. You can just type this command into a normal Windows console: The simplest case is something like the following which sends the string “hello” to COM1 (the first serial port). ![]() Instead you can just use Windows’ built-in echo, set and mode commands. I actually developed a small command line utility called SerialSend for doing exactly this, but in many cases you can get away without using any special programs at all. The sort of thing I might use this for is sending a command to a robot or other microcontroller-based device that I’m building using a USB-to-serial converter. ![]() 333 /*duration in seconds (round to nearest tenth).*/ call sound freq, secs /* " " " " 3/10 " */ /*stick a fork in it, we're done making noises.I often need to send short character strings to a serial port in Windows. */ call sound freq /*sounds PC speaker, duration=. ![]() */ call beep freq, ms /* " " " " " 1/2 " */ /* supported by PC/REXX & Personal REXX:*/įreq = 2000 /*frequency in (nearest) cycles per second. */ call beep freq /*sounds the PC speaker, duration= 1 second.*/ */ say copies (bell, 20 ) /*as above, but much more annoying. */ else bell = '07'x /* " " " " " ASCII " */ say bell /*sound the bell on the terminal. ║ ║ ║ ║ On an ASCII machine, it is (hexadecimal) '07'x. *REXX program illustrates methods to ring the terminal bell or use the PC speaker. Feel free to adjust this value out 42 h, al mov al, ah out 42 h, al mov al, 3 out 61 h, al enable sound and timer mode mov cx, 0 FFFFh mov dx, 0 Fh set up loop counters beepdelay: delay lasts about half a second loop beepdelay mov cx, 0 FFFFh dec dx jnz beepdelay mov al, 0 mute out 61 h, al cut the sound mov bl,15 mov ax,0E20h print a spacebar to the terminal int 10h uncomment these 3 lines if you want the BEL to "take up space" in the output stream pop dx pop cx pop ax ret end start Action! code start: mov al, 7 call PrintChar mov ax, 4 C00h int 21 h return to DOS PrintChar: Print AL to screen push cx push bx push ax cmp al, 7 jne skipBEL call RingBell jmp done_PrintChar skipBEL: mov bl, 15 text color will be white mov ah, 0 Eh int 10 h prints ascii code stored in AL to the screen (this is a slightly different putc syscall) done_PrintChar: pop ax pop bx pop cx ret RingBell: push ax push cx push dx if BEL is the argument passed to PrintChar, it will call this function and not actually print anything or advance the cursor this uses the built-in beeper to simulate a beep mov al, 10110110 b select counter 2, 16-bit mode out 43 h, al mov ax, 0 C00h set pitch of beep - this is somewhat high but isn't too annoying. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |